Reputation: 217
I'm strugling with finding info of how to ignore some tests that were exclusively written for some "other" profile when runing default mvn clean install.
I need different tests for different use cases:
I've got my custom test profile
public class IntegrationProfile implements QuarkusTestProfile {
@Override
public String getConfigProfile() {
return "integration";
}
@Override
public Set<String> tags() {
return Collections.singleton("integration");
}
}
And use it like this:
@QuarkusTest
@TestProfile(IntegrationProfile.class)
public class ArticleIntegrationRepositoryTest { ... }
I run these tests in cmd line like:
mvn -Dquarkus.test.profile.tags=integration clean install
But when I run
mvn clean install
all tests, including "profiled" ones are executed and I don't want that. Is there any way to annotate these "other" tests so they don't get run unles I specificaly execute them with mvn -Dquarkus.test.profile.tags=integration clean install
Any help appreciated
Upvotes: 3
Views: 1542
Reputation: 217
I figured it out:
First I addet junit 5 tag to to my integrations test classes
@Tag("integration")
then I updated my pom.xml files accordingly. For maven-surfire-plugin I added executions to ignore my integration tags on tests
<executions>
<execution>
<id>default-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<excludedGroups>integration</excludedGroups>
</configuration>
</execution>
</executions>
and added new integration profile to include only these tests when needed
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<id>quarkus-test</id>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>integration</groups>
</configuration>
</execution>
</executions>
...
</plugin>
</plugins>
</build>
</profile>
now mvn clean install ignores my "integration" tests and mvn -Dquarkus.test.profile.tags=integration -P integration clean install executes only integration tests
Upvotes: 2