我的文件中有大约 100 个测试方法testing.xml
。并且在 pom.xml 文件中配置了 testing.xml,所以我可以运行所有这些测试用例,maven test
并且我得到了正确的报告等等。
我已经创建了一个 Jenkins 作业并在其中进行了配置maven project
,并提到了本地的 pom.xml 文件路径。我能够成功运行。
我打算明智地分离一些测试用例类别,然后在另一个testing.xml
文件中进行管理。至少说 2 个 xml 文件有 50 50 个测试方法。
我被困在这里。是否可以在单独的 Jenkins 作业中配置每个 testing.xml 文件?如果是,那么我该如何配置?(注意:我必须运行 maven test 才能获取报告)
是的,您可以将 xml 文件名作为参数传递给 maven test 命令。首先需要修改pom文件如下。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${SuiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
然后,您为每次执行传递不同的文件名,例如,
mvn test -DSuiteXmlFile=mytestng1.xml
对于第二个 xml 文件,
mvn test -DSuiteXmlFile=mytestng1.xml
您可以使用不同的参数配置每个 jenkins 作业。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句