0
votes

I have JUnit 4 tests that run with JUnit Jupiter (JUnit 5) using the vintage engine and maven-surefire-plugin version 2.19.1.

[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ jon-snow ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (unit-tests) @ jon-snow ---

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.whatever.WhateverTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0 ...

When I upgrade the maven-surefire-plugin version to 2.22.1, no tests are detected.

[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ jon-snow ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (unit-tests) @ jon-snow ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Why is this? I have 248 tests that should run. What dependencies or config changes do I need to add to make tests work again?

1
Apparently JUnit 5 support was added with 2.22.0, I'd guess it now requires either actual JUnit 5 tests or the junit-vintage-engine artifact. Maybe related: stackoverflow.com/questions/36970384/…Marvin
Could you add your dependency set (at least in test scope) ?Loïc Le Doyen

1 Answers

2
votes

Similar to what @Marvin was stating, you will need to make sure you update your version of the jupiter engine plugin accordingly. Also if you're using an older jUnit version then utilize an updated dependency for it. A small sample with each is provided below.

   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven-surefire-plugin.version}</version>
    <dependencies>
      <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.5.2</version>
      </dependency>
    </dependencies>
    ...
   </plugin>

If you're using older jUnit dependencies include this dependency

   <dependency>
     <groupId>org.junit.vintage</groupId>
     <artifactId>junit-vintage-engine</artifactId>
     <version>5.5.2</version>
   </dependency>

In the sample above we are using maven-surefire-plugin version 2.22.2