我正在尝试使用@Category
- JUnit和配置文件的注释来拆分集成测试和冒烟测试。因此,如果我运行mvn clean install -P smoke-tests
,则只执行Smoke-Tests并且每次测试都运行mvn clean install
。
事情是:
当我使用<excludeGroups>
排除Maven中的群组时,会按预期排除群组。但是当我尝试用<groups>
包含它们时,它仍会运行每个测试。 Maven代码没什么特别的:
<profile>
<id>smoke-tests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<configuration>
<parallel>classes</parallel>
<threadCount>4</threadCount>
<perCoreThreadCount>false</perCoreThreadCount>
<!-- <excludeGroups>de.package.SmokeTest</excludeGroups> -->
<groups>de.package.SmokeTest</groups>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
当然,我可以使用<include>
和<exclude>
解决此问题,但我真的想使用@Category
注释。
感谢任何帮助。
答案 0 :(得分:1)
这是一个在2.12.1中修复的错误:JUnit categories only work when junit47 provider is explicitly set。如果您无法升级,请明确指定一个junit提供程序,它应该可以工作:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<groups>uk.co.farwell.test.SlowTests</groups>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</plugin>