I have a maven project with several modules and one common parent module. This unit runs some unit tests with Junit along with surefire, as well as integration tests for BDD Cucumber. I would like to run two separate jobs: one to run all unit tests and one to run BDD / Integration tests. To do this, I annotated my BDD runner classes with a unit category annotation as follows:
@RunWith(Cucumber.class) @CucumberOptions( tags = { "@ATagToBeRun", " ~@ATagNotToBeRun "," ~@ToBeImplemented " }, dryRun = false, strict = true, features = "src/test/resources/cucumber/testing", glue = { "com.some.company.test", "com.some.company.another.test"}) @Category(value = IntegrationTest.class) public class FlowExecutionPojoTest { }
I created a Maven profile in the parent pom
, which uses the maven-surefire-plugin
function, which is used to filter the test database on groups. Here is my maven configuration:
<dependencies> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.4</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.2.4</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-spring</artifactId> <version>1.2.4</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-jvm-deps</artifactId> <version>1.0.5</version> <scope>test</scope> </dependency> </dependencies> <profile> <id>testJewels</id> <activation> <activeByDefault>true</activeByDefault> </activation> <modules> <module>../my-module</module> </modules> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <configuration> <groups>com.some.company.IntegrationTest</groups> </configuration> </plugin> </plugins> </build> </profile>
I expected that when running mvn test -PtestJewels
, classes annotated by the category contained in the <groups>
tag should be executed. In fact, none of the annotated classes have been executed.
An interesting point is that when I used the maven-surefire-plugin
version 2.18, it worked, but from version 2.18.1 and it didn’t. According to the documentation at the bottom of the page, in version 2.18.1 there have been changes in relation to the inherited categories, but in my case they are in
source share