0

UPDATE

This is NOT a duplicate question. The quoted duplicate answer is something that I had reviewed already.

The issue for me was the version of the junit-vintage-engine that I was using 5.4.2 did not work 5.3.2 did.


Currently unable to get the maven-surefire-plugin to run JUnit4 tests in conjunction with JUnit5 tests with maven.

Surefire plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.22.1</version>
  <configuration>
    <includes>
      <include>**/*Test.java</include>
      <include>**/*Runner.java</include>
    </includes>
  </configuration>
</plugin>

When I add the aggregatejunit-jupiter (includes engine / params / api):

<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter</artifactId>
  <version>5.4.2</version>
  <scope>test</scope>
</dependency>

...and run mvn test the JUnit5 tests run but the old JUnit4 tests do not. When I remove it the JUnit4 tests run. junit is a provided by spring-boot-starter-test:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
</dependency>

I followed the instructions outlined here (JUnit docs), however this only resulted in the JUnit5 tests getting run. These instructions outline adding the vintage engine:

<dependency>
  <groupId>org.junit.vintage</groupId>
  <artifactId>junit-vintage-engine</artifactId>
  <version>5.4.2</version>
  <scope>test</scope>
</dependency>

Any help appreciated.

Thanks

Hurricane
  • 1,454
  • 1
  • 13
  • 31

0 Answers0