我试图通过从命令行指定测试套件来从命令行运行我的测试。在我的 pom 文件中,它显示“无法解析符号‘suiteXmlFile’(对于 ${suiteXmlFile)。如果我在 pom 文件中指定 WebCheckout.xml 的名称,它会起作用,但我希望能够从命令行运行它,例如这个:
mvn clean test -Dsurefire.suiteXmlFiles=WebCheckout.xml
我一直在关注本教程:
http://www.seleniumeasy.com/maven-tutorials/choose-selected-testng-xml-files-to-execute-using-maven
我的pom文件配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
请有人告诉我哪里出了问题。
最佳答案
This is an issue affecting 2.12 (以及可能的早期版本),所以只需使用 Surefire 插件 version >= 2.18.1它已被修复的地方。我尝试了 2.21.0(最新的 ATM),它按预期工作(尽管我的 XML 位于 test/resources
目录中,所以我必须指定 -Dsurefire.suiteXmlFiles=src\test\resources\test.xml
)
关于java - Maven TestNG - 无法从命令行指定测试套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49174963/