'Include testing test groups for failsafe (integration testing) only but exclude them from surefire

The following config does not work. No test is in scope for the goal integration-test.

In case it is unclear, What should happen is that what I do a mvn integration-test the failsafe plugin should run my test. But the surefire plugin configuration is excluding the test. If I uncomment the surefire config block the test is run during the integration-test goal.

Maven config:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <groups>spring-container-sanity</groups>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <excludedGroups>spring-container-sanity</excludedGroups>
            </configuration>
        </plugin>
    </plugins>
</build>

A Java Test class

@SpringApplicationConfiguration(TestApplication.class)
@TestPropertySource("/test.properties")
public class SimpleTest extends AbstractTestNGSpringContextTests {
    @Test(groups = "spring-container-sanity")
    public void isHessianServiceExported() throws Exception {
      /*...*/

    }
}


Solution 1:[1]

When annotating your test, make sure to define an array of groups, even if its only a single one.

@Test(groups = {"spring-container-sanity"})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mads Rangholm