問題描述
我對 maven 和 testng 完全陌生.我使用 maven 作為構建工具,并使用 testng 作為我的測試框架.我沒有遵循標準的 Maven 項目結構.現在我希望我的 pom.xml
在我的項目中執行測試用例.問題是,pom.xml
如何知道要考慮執行哪些測試用例?
如果你把它放在一個地方,你需要設置 maven-surefire-plugin 配置的 testClassesDirectory
參數:
<代碼><項目>[...]<構建><插件><插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><版本>2.17</版本><配置><testClassesDirectory>路徑/到/編譯的測試類</testClassesDirectory></配置></插件></插件></構建>[...]</項目>
所有這些都在 Maven Surefire 插件文檔中詳細記錄了p>
I am completely new to maven and testng. I am using maven as build tool, and testng as my testing framework. I am not following the standard maven project structure. Now I want my pom.xml
to execute the test cases in my project. The question is, how pom.xml
knows what are the test cases to consider for execution?
If you keep this in a single place you need to set the testClassesDirectory
argument of the maven-surefire-plugin configuration:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<testClassesDirectory>path/to/compiled test classes</testClassesDirectory>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
All of this is well documented in the Maven Surefire Plugin Documentation
這篇關于maven pom.xml 如何識別非標準項目結構中的 testng 測試用例?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!