Maven fault tolerant plugin will not run test classes annotated with JUnit Category

I have an interface like this:

public interface IntegrationTest { } 

I configure the protected plugin as follows:

  <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.14</version> <configuration> <groups>acme.test.IntegrationTest</groups> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> </goals> </execution> </executions> </plugin> 

If I then create an integration test like this

 @Category(IntegrationTest.class) public class ExampleClassIntegrationTest { @Test public void slow_and_painful_test() { 

This test will not run.

If I, however, call the class according to the inclusion and exclusion of tests

 **/IT*.java **/*IT.java **/*ITCase.java 

Same:

 @Category(IntegrationTest.class) public class ExampleClassIT { @Test public void slow_and_painful_test() { 

The test runs fine. Why should I name a test? Do I have an annotation when I use the groups-tag? Am I missing something? The documentation for using JUnit states that you can use Category annotation at the class level.

+4
source share
2 answers

This is because these are the default java classes that do not allow a secure plugin to be included at runtime. You can, however, drive this on your estate with the tag: For example

 <includes> <include>**/*.java</include> </includes> 

To include all java files.

+7
source

You must either add JUnit as a dependency (> 4.8) that has already been executed, or, in particular, add the following to the configuration of the failover plugin:

 <plugins> [...] <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.14.1</version> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> <version>2.14.1</version> </dependency> </dependencies> </plugin> [...] </plugins> 

But I assume that this will not change the situation.

0
source

Source: https://habr.com/ru/post/1483131/


All Articles