【发布时间】:2019-07-17 06:25:05
【问题描述】:
我想根据从 jenkins 传递的变量运行测试用例,例如,如果我从 jenkins 中选择 TestCaseForHistoryPage,它应该只运行。
我的 testng,xml 看起来像:
<test name="TestCaseForInlineRedemption">
<classes>
<class name="test_cases.TestCaseForInlineRedemption">
</class>
</classes>
</test> <!-- Test -->
<test name="TestCaseForHistoryPage">
<classes>
<class name="test_cases.TestCaseForHistoryPage">
</class>
</classes>
</test>
And pom like:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<systemPropertyVariables>
<testnames>${Dtest}</testnames>
<country>${Dcountry}</country>
<environment>${Denvironment}</environment>
</systemPropertyVariables>
<testFailureIgnore>true</testFailureIgnore>
<suiteXmlFiles>
<!-- TestNG suite XML files -->
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemProperties>
<property>
**<test>${Dtest}</test>**
</property>
</systemProperties>
</configuration>
</plugin>
我想通过 pom 将 jenkins 中的 ${Dtest} 传递给 testng。
有人可以帮忙吗?
【问题讨论】:
-
可以通过
-Dtest=TestCircle test运行单个测试,甚至可以通过mvn -Dtest=TestCircle#mytest test等运行一个测试用例的单个方法。查看详情maven.apache.org/surefire/maven-surefire-plugin/examples/…
标签: maven selenium jenkins testng pom.xml