question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JUnit tests not executed or failures with Junit 5 & Surefire >= 3.0.0-M4

See original GitHub issue

Describe the bug With the latest versions of the surefire plugin, no features are executed, or the run fails entirely.

To Reproduce Steps to reproduce the behavior: Use the example from: https://github.com/bonigarcia/mastering-junit5/tree/b19313dc1f6a1b7c4421e84ac9d6afd117c218d5/junit5-cucumber Run it once, everything works fine (surefire 2.22.2):

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

In the POM, change surefire to 3.0.0-M3, all still good:

Tests run: 4, Failures: 0, Errors: 0, Skipped: 0

In the POM, change surefire to 3.0.0-M4, tests are executed (can check with stdout ‘ADD’ in steps), but not reported:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
ADD
ADD
ADD
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

In the POM, change surefire to 3.0.0-M5, tests are executed (can check with stdout ‘ADD’ in steps), but not reported, and an error is logged:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[ERROR] jul 06, 2021 9:47:26 AM org.junit.platform.launcher.core.LauncherConfigurationParameters loadClasspathResource
[ERROR] INFO: Loading JUnit Platform configuration parameters from classpath resource [file:/C:/workspace/IdeaProjects/junit5-cucumber/target/test-classes/junit-platform.properties].
ADD
ADD
ADD
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Context & Motivation We just want to use Junit5 + Cucumber, but with the latest versions of everything it just doesn’t work. Since the results are not reported to surefire, it also doesn’t fail on errors, so we don’t notice if there’s a problem.

Your Environment

  • Cucmber 6.10.4
  • Junit-Jupiter 5.7.2
  • Windows 10
  • Maven 3.8.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mpkorstanjecommented, Aug 16, 2021

With Cucumber v7 (not yet released) and JUnit 5.8 (not yet released) we will deprecate @Cucumber in favour of @Suite. This should coincidently fix the issue with Surefire > M4.

Add:

<dependency>
   <groupId>org.junit.platform</groupId>
   <artifactId>junit-platform-suite</artifactId>
   <version>${junit-platform.version}</version>
   <scope>test</scope>
</dependency>

Then use:

package com.example;

import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;

import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;

@Suite
@SelectClasspathResource("com/exmaple")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example")
public class RunCucumberTest {
}

To improve the readability of the reports provide the cucumber.junit-platform.naming-strategy=long configuration parameter.

1reaction
mpkorstanjecommented, Aug 5, 2021

This is not a problem with Cucumber. Please do not report additional instances. Do upvote the issue in the Surefire bug tracker:

https://issues.apache.org/jira/browse/SUREFIRE-1849

edit: @aSemy fixed the mistake in message. Cheers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven Surefire not running JUnit 5 tests - java - Stack Overflow
There are two things. First you should upgrade jacoco dependency to 0.8.5 otherwise it fails based on the JDK14 requirement.
Read more >
[#SUREFIRE-1813] Version 3.0.0-M5 fails to find Junit tests ...
Maven Surefire Plugin Version 3.0.0-M5 fails to find and run JUnit 5 tests, while 3.0.0-M4 seems to do it fine. All things other...
Read more >
Why Your JUnit 5 Tests Are Not Running Under Maven
There is a very common issue preventing your JUnit 5 tests from running under Maven. In this post, I explain why and provide...
Read more >
Problem running JUnit5 tests with Maven Surefire
Hello. I'm trying to run my unit tests written with JUnit5 with maven. I have configured relevant pom.xml sections like this : dependencies ......
Read more >
Test not failing if BeforeAll crashes #2178 - junit-team/junit5
[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) @ junit_fail ... JunitFailTest [INFO] Tests run: 0, Failures: 0, Errors: 0, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found