我已经在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] ------------------------------------------------------------------------
我已经尝试了所有博客来解决此问题,但是没有运气。
这真的很有帮助,有人可以帮助我解决这个问题。