我在設定我的專案以供 testng 使用時遇到問題。背景是我想用 maven 命令列執行我的 test.xml。我在我的 pom.xml 的構建部分中使用了這個插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
但是...當我呼叫mvn clean test -DxmlSuiteFile=test.xml
所有單元測驗時,我的所有單元測驗都已執行,但 test.xml 未受影響。
當我將surefire的版本更改為2.22.2一切正常時。但我收到訊息:testSuiteXmlFiles0 has null value
僅在運行時mvn test
我很困惑如何讓它與 surefire 3.0.0-M5 一起運行?
uj5u.com熱心網友回復:
-DxmlSuiteFile=test.xml如果它已經在 pom.xml 中定義,則不需要。
嘗試明確定義 surefire testNG 提供者:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
test.xml檔案應該在專案根目錄中。
另請參閱: https ://maven.apache.org/surefire/maven-surefire-plugin/examples/providers.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/440897.html
標籤:爪哇 行家 测试 maven-surefire-插件
