Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven failsafe plugin will not run test classes annotated with JUnit Category

I have an interface like this:

public interface IntegrationTest {
}

I configure the failsafe plugin like this:

 <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 name the class according to the Inclusions and Exclusions of Tests

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

Like so:

@Category(IntegrationTest.class)
public class ExampleClassIT {

@Test
public void slow_and_painful_test() {

The test runs fine. Why do I have to name the test AND have an annotation when i use the groups-tag? Am I missing something? The documentation on using JUnit states that you can use the Category annotation at the class level.

like image 519
Jörgen Lundberg Avatar asked Jan 14 '23 06:01

Jörgen Lundberg


1 Answers

Thats because these are the default java classes which fail safe plugin includes when executed. You can however over ride this in your pom with tag : E.g

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

To include all the java files.

like image 196
Madhusudanan K K C Avatar answered Apr 26 '23 19:04

Madhusudanan K K C