java如何在Jenkins中拆分JUnit测试
我正在尝试使用Junit类别为Jenkins划分测试。我在网上阅读了所有的指南,并做了以下工作
- 创建了一个接口
public interface regression {}
- 为测试添加了注释
@Category(regression.class)
@Test
public void myTest(){}
- 将组添加到POM。XML
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>test_listener.TestListener</value>
</property>
</properties>
<groups>categories.regression</groups>
</configuration>
</plugin>
我写了以下终端:
mvn clean test -Dtest=categories.regression
并收到此错误消息:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project automation: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
# 1 楼答案
我将尝试再次运行该命令,但使用
-Dgroups=categories.regression
而不是-Dtest
此外,请查看: