D:> java -cp“Pathtolibfolder \ lib *; Pathtobinfolder \ bin”org.testng.TestNG testng.xml
有任何想法吗?
如果您正在使用Maven,那么我只需使用surefire插件并运行测试作为构建的一部分:
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>RELEASE</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
...
</plugins>
只需指定testng.xml的路径,并在可以使用此类配置时利用它。它允许大量的参数化,我已经在我的项目中广泛使用它。
查看本教程,了解它:http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html