Junit5: Surefire can't find class `org.apache.maven.plugin.surefire.log.api.ConsoleLogger`

Created on 13 Apr 2018  路  14Comments  路  Source: junit-team/junit5

Maven Surefire Platform bug

Most helpful comment

When you update to Surefire 2.20.0, make sure to remove your junit-platform-surefire-provider plugin dependency declaration for the surefire plugin or you will keep getting this error.

All 14 comments

Copied from https://github.com/junit-team/junit5/issues/801#issuecomment-380886634 written by @joakime

--

There are 4 separate projects.
All 4 use the same version of maven-surefire-plugin

Project Name | Description | Behavior
-------------- | ----------- | ---------
junit5-forkcount-1 | Junit 5 provider, Using <forkCount>1</forkCount> | Crashes with org.apache.maven.plugin.PluginExecutionException :boom:
junit5-forkmode-always | Junit 5 provider, Using <forkMode>always</forkMode> | Crashes with org.apache.maven.plugin.PluginExecutionException :boom:
junit4-forkcount-1 | Junit 4 default, Using <forkCount>1</forkCount> | Terminates with org.apache.maven.plugin.MojoFailureException :heavy_check_mark:
junit4-forkmode-always | Junit 4 default, Using <forkMode>always</forkMode> | Terminates with org.apache.maven.plugin.MojoFailureException :heavy_check_mark:

So, there's 2 maven-surefire-plugin configurations that make the junit 5 surefire provider crash, but not the older junit 4 surefire provider ...

Scenario 1: forkCount with reuseForks

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.21.0</version>
        <configuration>
          <forkCount>1</forkCount>
          <reuseForks>false</reuseForks>
        </configuration>
      </plugin>

Scenario 1: forkMode = always

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.21.0</version>
        <configuration>
          <forkMode>always</forkMode>
        </configuration>
      </plugin>

I am also seeing this. If reuseForks is set to true, Surefire will always crash with the CNFE and no tests are executed.

  • 1 Parallel runs don't seem to function properly, I attempted to resort to forkCount, and was met with the same error.
    Not sure if there is an additional error that is preventing me from running properly, or if this error specifically is the root cause.

In any case the error is consistent with OP's:
Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test failed: java.lang.ClassNotFoundException: org.apache.maven.plugin.surefire.log.api.ConsoleLogger

This is still broken. Have we an ETA when this will be fixed?

These are versions of plugins and JUnit 5 I'm using:

     <surefire.plugin.version>2.21.0</surefire.plugin.version>
    <dep.junit.jupiter.version>5.2.0</dep.junit.jupiter.version>
    <dep.junit.vintage.version>5.2.0</dep.junit.vintage.version>
    <dep.junit.platform.version>1.2.0</dep.junit.platform.version>

This issue will be solved as soon as Surefire has native support for the JUnit platform (cf. https://github.com/apache/maven-surefire/pull/184).

For now, please add the following to the build > dependencies block of your POM:

    <dependency>
      <groupId>org.apache.maven.surefire</groupId>
      <artifactId>surefire-logger-api</artifactId>
      <version>2.21.0</version>
      <!-- to get around bug https://github.com/junit-team/junit5/issues/1367 -->
      <scope>test</scope>
      <optional>true</optional>
    </dependency>

@joakime @triceo @bigkahuna1uk @chibenwa As Surefire 2.22.0 is released, may you please re-run your setup and verify if the issue still persists using the latest-and-greatest version with native JUnit Platform support?

Thanks in advance.

Works like a charm, @sormuras. Thanks!

@sormuras we have enabled Surefire 2.22.0 in our junit5 branch - eclipse/jetty.project@af7b52d32306bf3996a0e0e983d3ecce7d48d1e2

So far, with nearly a dozen features disabled, it seems to be working.
jacoco plugin doesn't work.
osgi paxexam doesn't like it.
Threaded testing with -T3 is broken at the moment too.
@{argLine} support seems to have been broken.
forkMode and forkCount haven't been tested properly (yet). (still chasing broken tests from the junit5 conversion)

@joakime Just tried it and鈥'm still using 2.19.1!

When you update to Surefire 2.20.0, make sure to remove your junit-platform-surefire-provider plugin dependency declaration for the surefire plugin or you will keep getting this error.

@sormuras I think we can fix this issue now that Surefire 2.22.0 is released with native support for JUnit Platform, right?

Closing this issue -- please report new issues at https://maven.apache.org/surefire/issue-tracking.html

Using [email protected] and versions of junit-jupiter(5.2.0) and junit-platform(1.2.0) here. When enabling

            <forkCount>3</forkCount>
            <reuseForks>true</reuseForks>

the plugin still fails with the same error.

@silkentrance,

As @sormuras mentioned:

Closing this issue -- please report new issues at https://maven.apache.org/surefire/issue-tracking.html

I am therefore locking this issue.

Further discussions regarding Maven Surefire's support for the JUnit Platform should take place in the Maven Surefire issue tracker.

Was this page helpful?
0 / 5 - 0 ratings