-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Junit Platform] Deprecate @Cucumber in favour of @Suite #2362
[Junit Platform] Deprecate @Cucumber in favour of @Suite #2362
Conversation
d488ff0
to
9a1a1b8
Compare
Waiting for JUnit 5.8 to be available. |
Codecov Report
@@ Coverage Diff @@
## v7.x.x #2362 +/- ##
============================================
- Coverage 83.33% 83.24% -0.10%
+ Complexity 2324 2323 -1
============================================
Files 296 296
Lines 8301 8309 +8
Branches 737 737
============================================
- Hits 6918 6917 -1
- Misses 1098 1103 +5
- Partials 285 289 +4
Continue to review full report at Codecov.
|
9a1a1b8
to
e30e0d3
Compare
e30e0d3
to
ff12508
Compare
This sounds great! When something is deprecated I think docs should etc should document the new way rather than the old. We need a ticket to keep track of what needs to be updated. Quick brain dump:
|
The We can replace JUnit 4 with JUnit 5 now in the docs.cucumber.io though.
Part of this repo. Already covered.
https://github.com/cucumber/cucumber-java-skeleton/pull/64/files
Only thing left to do. |
@mpkorstanje For my use-case, I need to be able to run <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.my.company.package.RunCucumberTest</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build> Linking the class name Including an empty main method within class @Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/example/application")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example.application")
public final class RunCucumberTest {
public static void main(String[] args) {}
} will do nothing when run from the fat-jar (for obvious reasons). Back in JUnit 4 platform, my solution to this was: import org.junit.runner.JUnitCore;
...
public final class RunCucumberTest {
public static void main(String[] args) {
JUnitCore.main(RunCucumberTest.class.getName());
}
} What is the correct JUnit 5 References: https://stackoverflow.com/questions/66563561/run-test-suite-class-with-junit-5-programmatically |
The JUnit 5 equivalent of https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher Cucumber also has a main method of it's own: |
This seems to work: import io.cucumber.core.cli.Main;
...
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/my/company/package/features")
@ConfigurationParameters({
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty"),
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "html:target/report/cucumber.html"),
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "json:target/report/cucumber.json"),
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "junit:target/report/cucumber.xml"),
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "not @Ignore"),
@ConfigurationParameter(key = PLUGIN_PUBLISH_QUIET_PROPERTY_NAME, value = "true")
})
public final class RunCucumberTest {
public static void main(String... args) {
Main.main();
}
} However, if Is there a way to pass a reference to the I don't see such a possibility in the method signatures of |
Either you run Cucumber directly through it's own main method. Or you run Cucumber through JUnit 5. If you run Cucumber directly, any instructions for JUnit related to running Cucumber will be ignored. If you run Cucumber directly you don't need and can remove any and all parts related to JUnit 5 from your project. If you do run Cucumber through JUnit 5 and you want to run JUnit 5 from a main method you have to use the Console Launcher provided by JUnit 5. |
The CucumberJUnit Platform Engine has been updated to 1.8. With JUnit 5.8 comes
the
junit-platform-suite
engine. This engine allows theprogrammatic declaration of test suites.
So it is now possible to write the following JUnit 4 test:
As a declarative JUnit 5 test suite:
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