![](/img/trans.png)
[英]NullPointerException in maven-surefire-plugin when running testng suite xml with maven
[英]Run TestNG suite from maven getting error:maven-surefire-plugin:test failed: testSuiteXmlFiles0 has null value
我在這里看到很多關於使用Maven surefire插件運行TestNG套件的帖子。 示例說要將其添加到pom中:
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testSuite}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
然后這到命令行:
mvn test -DtestSuite=myCustomSuite.xml
我的問題是它將你綁定到使用TestNG套件...例如,如果我想運行這樣的組:
mvn test -Dgroups=myGroup
我收到此錯誤:
maven-surefire-plugin:2.18.1:測試失敗:testSuiteXmlFiles0具有空值
我希望能夠從命令行運行套件路徑或組。
您可以:不使用屬性的surefire配置,而是:
mvn test -DtestSuite=myCustomSuite.xml
配置並用mvn test -Dsurefire.suiteXmlFiles=myCustomSuite.xml
替換mvn test -DtestSuite=myCustomSuite.xml
mvn test -Dsurefire.suiteXmlFiles=myCustomSuite.xml
。 請參閱Surefire文檔 mvn test -Dgroups=myGroup
。 由於將刪除testSuiteXmlFiles0 has null value
配置,因此-Dgroup
選項將不會出現錯誤testSuiteXmlFiles0 has null value
。
您還可以使用maven配置文件,它將配置surefire插件,具體取決於您傳遞給maven的屬性。
<profiles>
<profile>
<id>suite</id>
<activation>
<property>
<name>testSuite</name>
</property>
</activation>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testSuite}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</profile>
</profiles>
出於某種原因,接受的答案對我不起作用。 我使用了類似的東西。
mvn test -Dgroups=myGroup -DtestSuite=" "
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.