为了在命令行上运行TestNG测试,我必须在classpath中设置TestNG。为此,我经历了 -
Unable to execute TestNG Suite file via command line
Getting error Could not find or load main class org.testng.TestNG
这告诉如果testng.jar
在项目的lib
文件夹中,那么在classpath中设置路径直到lib
文件夹(如-C:\Workspace\projectname\lib\*
)。
但在我的情况下,我正在使用Maven项目,因此没有lib
文件夹放罐子。在这种情况下,如何在类路径中设置TestNG?因此在命令行上运行TestNG测试。
如果您正在使用maven,您是否尝试使用该命令运行测试
mvn test -DsuiteXmlFile=<xml file>
mvn test -D <suiteXmlFile.xml>
为调试日志添加'-X'
,此命令运行良好。
真的推荐。
我有与上面相同的问题
Below is pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.project</groupId>
<artifactId>WeWalkThru</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>