I am facing this issue in my Spring MVC project:
I have two types of tests. Unit and Integration. Both separated by package in test/java, respectively by test/java/unit and test/java/integration. I am using maven-surefire plugin to trigger tests.
I have two profiles, unit and integration defined in pom.xml
<profile>
<id>unit</id>
<properties>
<include.tests>**/unit/**/*.java</include.tests>
</properties>
</profile>
<profile>
<id>integration</id>
<properties>
<include.tests>**/integration/**/*.java</include.tests>
... other properties for configuring integration platform (DB, ...) omitted for simplicity
</properties>
</profile>
And surefire plugin is configured like this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<includes>
<include>${include.tests}</include>
</includes>
</configuration>
</plugin>
When I run mvn surefire:test -Punit, all unit tests are triggered, which is what I want (I´ve checked the amount of tests passed is same as amount of tests passed when I trigger them by unit folder for example from IDEA).
But when I try to run mvn surefire:test -Pintegration, the task will run and "succeed", but the number of tests peformed is 0. But when I run these tests from IDEA for example with Integration profile active, I see there is X tests which will run successfully.
Basic integration tests uses @RunWith(SpringJUnit4ClassRunner.class) for running test (plus some config xmls to configure other properties).
Unit tests are JUnit 5 based using Mockito.
Aucun commentaire:
Enregistrer un commentaire