Reputation: 5093
I have a work environment including bom I dont manage and JUnit5 tests are not picked up unless I import my @Test
annotation for test methods from import org.junit.Test;
if I import them from import org.junit.jupiter.api.Test;
they are not picked up by maven surefire plugin.
I read in many parts and tested in a smaller project and its working and pickedup, I don't know what to include into this post so you have enough information to see where is the issue.
Also if anybody can explain what is under the hood for the imports I read are needed for both JUnit 4 and 5 to work with surefire namely
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<!--JUnit Jupiter Engine to depend on the JUnit4 engine and JUnit 4 API -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
with versions
<maven.surefire.version>3.0.0-M5</maven.surefire.version>
<junit-jupiter.version>5.1.0</junit-jupiter.version>
I'd appreciate that.
Note that
Upvotes: 0
Views: 474
Reputation: 5093
Found that this dependency was conflicting, removing it solved my issue
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.8.2</version>
<scope>test</scope>
</dependency>
also updated spring-boot-dependencies version to 2.6.6
, had issues with 2.3.3.RELEASE
Upvotes: 0