我有一个用 Intellij 想法编写的 Maven 项目(appium/java)。要运行测试,我必须运行 testng.xml 文件。我想从命令行运行我的测试脚本。我怎样才能做到这一点?我找到了从命令行运行 testng.xml 的各种链接,但没有一个解决方案适合我。提前致谢
由于您的项目是 Maven 项目,因此您可以在导航到项目路径后从命令行使用选项mvn clean test。这将运行 testng.xml 文件中的测试
如果您有多个测试 xml 文件,您可以使用Surefire 插件。在 pom.xml 中,您需要添加如下内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFiles}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
添加尽可能多的suiteXmlFile标签,它应该指向你的test1.xml、test2.xml等的位置,然后在命令行中使用命令
mvn clean test -DsuiteXmlFile.suiteXmlFiles=path/to/test1.xml
如果要运行多个测试 xml 文件,可以使用以下命令
mvn clean test -DsuiteXmlFile.suiteXmlFiles=path/to/test1.xml,path/to/test2.xml
希望这可以帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句