我目前正在開發一個Maven支持的項目。我選擇了TestNg來實現我的單元測試。爲了在每個Maven構建運行我的幺測試,我已經添加了Maven的萬無一失,插件我的pom.xml:帶有TestNg的Maven-surefire-plugin:如何指定存儲測試套件xml文件的目錄?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<!-- Configuring the test suites to execute -->
<suiteXmlFiles>
<suiteXmlFile>testsuite-persistence-layer.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
此外,我要指定使用TestNG的TestSuiteXmlFile執行的測試。例如,在我的pom.xml中,我配置了surefire插件,以便它將執行名爲「testsuite-persistence-layer.xml」的xml文件中定義的測試。
問題是,默認情況下,surefire插件似乎是在我的項目的根目錄下查找這個xml文件。 如何指定surefire插件應該查找TestSuite xml文件的目錄?
根據TestNg文檔,這可以通過「maven.testng.suitexml.dir」屬性指定,但Surefire插件似乎沒有考慮到它。
非常感謝您的幫助!不知道,也沒有嘗試在標籤內指定一個相對於項目根的路徑 –
kyiu
其他方式是在一組接下來的命令集之後運行mvn -D測試$ {path}/test1 test,mvn -D測試$ {路徑}/TEST2測試和依賴關係是 org.apache.maven.plugins 行家-萬無一失-插件 2.12 <結構> <! - 套件從命令行輸入文件注入參數 - > $ {tests} .xml suiteXmlFile> suiteXmlFiles> configuration> –
Badrinath