java - maven 构建成功,但我的 java 代码没有被执行
问题描述
我在 Eclipse IDE 中编写了一段 java 代码。我的代码在 src/test/java 目录下,并且在 src/main/java 有一个虚拟类,并且能够通过在 eclipse 中使用 testng 来运行我的代码。
src/main/java 中的代码:
package Maven.Maven1;
public class MainJavaProgram {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Java program uder src-main-java is running");
}
}
src/test/java 中的代码(期望被执行):
package com.TestClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class MyFirstProgram {
@Test
public void TestMethod() {
//public static void main(String arg[]) {
System.out.println("Welcome to DevOps");
System.setProperty("webdriver.chrome.driver", "C:\\WebDrivers\\chromedriver_win32\\chromedriver.exe");
WebDriver driver= new ChromeDriver();
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
System.out.println("ChromeDriver is successfully launched");
driver.get("https://www.google.com/");
System.out.println("You are in Given webPage");
String title=driver.getTitle();
System.out.println("Title is " +title);
driver.quit();
}
}
当我尝试使用 maven 在命令提示符下执行相同操作时,我的构建已成功,但代码未执行。
使用的 maven 命令: mvn clean install 结果:
C:\EclipseCode\Maven1>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< Maven:Maven1 >----------------------------
[INFO] Building Maven1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Maven1 ---
[INFO] Deleting C:\EclipseCode\Maven1\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Maven1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\EclipseCode\Maven1\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Maven1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\EclipseCode\Maven1\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Maven1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\EclipseCode\Maven1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Maven1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\EclipseCode\Maven1\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Maven1 ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ Maven1 ---
[INFO] Building jar: C:\EclipseCode\Maven1\target\Maven1-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Maven1 ---
[INFO] Installing C:\EclipseCode\Maven1\target\Maven1-0.0.1-SNAPSHOT.jar to C:\Users\ELCOT\.m2\repository\Maven\Maven1\0.0.1-SNAPSHOT\Maven1-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\EclipseCode\Maven1\pom.xml to C:\Users\ELCOT\.m2\repository\Maven\Maven1\0.0.1-SNAPSHOT\Maven1-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.106 s
[INFO] Finished at: 2019-03-22T21:39:44+05:30
[INFO] ------------------------------------------------------------------------
我已经尝试了所有博客来解决这个问题,但没有运气。
这真的很有帮助,有人可以帮我解决这个问题。
解决方案
推荐阅读
- python - 如何正确使用 scipy.interpolate 中的常规网格插值器?
- javascript - 如果有任何失败,则取消获取链
- c# - 如何通过 HTTP 方法修改 NET API 控制器类的属性
- reactjs - Antd、ReactJs、路由和组件渲染问题
- url - GET 上的 .net 核心电子邮件验证链接无法将“System.GUID”类型的对象转换为“Sytem.String”类型的对象
- python - seaborn: 'rows' 和 'x_vars' 同时
- architecture - 管理具有不同价格的多个并发订阅的计费周期的最佳方法是什么?
- cytoscape.js - 如何在 cytoscape.js 中垂直对齐 dagre 父节点
- r - PlotlyR - 散点图例
- raku - 有没有办法检测某些东西是否不可变?