-
-
Notifications
You must be signed in to change notification settings - Fork 2k
JUnit tests not executed or failures with Junit 5 & Surefire >= 3.0.0-M4 #2331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You may be expecting a bit too much from a milestone release. That said, as you are using Cucumber through the JUnit Platform the problem is probably somewhere between Surefire and the JUnit Platform rather then Cucumber. You may want to file an issue there instead. |
And I think it's because this section does not include a check for |
And there is quite a few more bits of code that assume that tests have a class source. |
I'll revert to an older surefire version for now then. Wasn't actually sure what -M meant, I know -RC and -Beta and such :) |
And thank you for your attention, it's certainly appreciated :) |
Let's keep this open. Just in case some one else has time to do the leg work. |
Ah, I've just found this issue. Thanks for making it. I've discovered that excluding nothing and including all .java files results in one test running (even though I have ~250 scenarios. It's better than
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<excludes>
<!-- Don't exclude any @Test by default -->
<exclude/>
</excludes>
<includes>
<include>**/*.java</include>
</includes>
</configuration>
</plugin> I'm using the following dependencies
and excluding junit vintage org.junit.vintage:junit-vintage-engine |
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. |
With Cucumber v7 (not yet released) and JUnit 5.8 (not yet released) we will deprecate 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 |
The CucumberJUnit Platform Engine has been updated to 1.8. With JUnit 5.8 comes the `junit-platform-suite` engine. This engine allows the [programmatic declaration of test suites](https://junit.org/junit5/docs/current/user-guide/#test-suite). So it is now possible to write the following JUnit 4 test: ```java package com.example; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import org.junit.runner.RunWith; @RunWith(Cucumber.class) @CucumberOptions(glue = "com.example.application", features = "classpath:com/example/application") public class RunCucumberTest { } ``` As a declarative JUnit 5 test suite: ```java package com.example; import org.junit.platform.suite.api.ConfigurationParameter; import org.junit.platform.suite.api.IncludeEngines; 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 @IncludeEngines("cucumber") @SelectClasspathResource("com/example/application") @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example.application") public class RunCucumberTest { } ``` In combination with the before-all and after-all hooks this allows for a feature-complete migration from JUnit 4. And allows us to deprecate the `@Cucumber` annotation in favour of `@Suite`. Fixes: #2331
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):
In the POM, change surefire to 3.0.0-M3, all still good:
In the POM, change surefire to 3.0.0-M4, tests are executed (can check with stdout 'ADD' in steps), but not reported:
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:
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
The text was updated successfully, but these errors were encountered: