Upgrading maven-surefire-plugin from 2.19.1 to 2.22.1 causes tests to not run
Asked Answered
S

1

0

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?

Skatole answered 19/3, 2019 at 22:29 Comment(2)
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: #36970884Wellesz
Could you add your dependency set (at least in test scope) ?Impassive
V
3

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

Villon answered 25/12, 2019 at 6:26 Comment(1)
This worked for me. I also added the <scope> to be test. Thanks.Brookins

© 2022 - 2024 — McMap. All rights reserved.