Skip to content
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] Support cucumber.features property #2498

Merged
merged 1 commit into from Mar 11, 2022

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Mar 8, 2022

Usually it not necessary to use the cucumber.features property. See the notes section below.

JUnit 5 support is still anything but first class junit-team/junit5#2849. As such users
do need a quick and easy way to select feature files from the
commandline i.e:

mvn test -Dcucumber.features=path/to/example.feature

When enabled, other discovery selectors will be ignored. As such it would be prudent to select only the cucumber engine for execution with -Dsurefire.includeJUnit5Engines=cucumber and enabling pretty printing with -Dcucumber.plugin=pretty. I.e:

mvn test -Dsurefire.includeJUnit5Engines=cucumber -Dcucumber.plugin=pretty -Dcucumber.features=path/to/example.feature 

Of all possible options is the least-worst solution. Additionally a warning is logged prompting users to request better support. The relevant issues to request/support/sponsor are:


Note: Usually it not necessary to use the cucumber.features property.

  • When using the @Suite annotation use the JUnit 5 Suite annotations dedicated to selecting tests. I.e: @SelectClasspathResource or @SelectFile.

  • When using the JUnit Platform Launcher API, use DiscoverySelectors.selectClasspathResource or DiscoverySelectors.selectFile.

  • When using the JUnit ConsoleLauncher use the --select-file or --select-classpath-resource CLI options.

Note: Rerun files are not (yet?) supported with JUnit 5. See: #2805.

@codecov
Copy link

codecov bot commented Mar 8, 2022

Codecov Report

Merging #2498 (946e6bc) into main (517c5fb) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2498      +/-   ##
============================================
+ Coverage     83.70%   83.76%   +0.05%     
- Complexity     2677     2688      +11     
============================================
  Files           319      319              
  Lines          9438     9471      +33     
  Branches        916      917       +1     
============================================
+ Hits           7900     7933      +33     
  Misses         1201     1201              
  Partials        337      337              
Impacted Files Coverage Δ
...r/junit/platform/engine/CucumberEngineOptions.java 97.14% <100.00%> (+0.36%) ⬆️
...nit/platform/engine/DiscoverySelectorResolver.java 95.74% <100.00%> (+1.80%) ⬆️
...ucumber/junit/platform/engine/FeatureResolver.java 100.00% <100.00%> (ø)
...er/junit/platform/engine/TestDescriptorOnLine.java 90.62% <100.00%> (+1.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 517c5fb...946e6bc. Read the comment docs.

@aslakhellesoy
Copy link
Contributor

Amazing - just what I need!

@mpkorstanje mpkorstanje force-pushed the support-cucumber.features-property branch 4 times, most recently from 45db487 to 3983d4e Compare March 9, 2022 00:18
@mpkorstanje mpkorstanje force-pushed the support-cucumber.features-property branch 3 times, most recently from 54ae0d5 to 0b72aa2 Compare March 9, 2022 00:49
@mpkorstanje mpkorstanje marked this pull request as ready for review March 9, 2022 00:50
@mpkorstanje mpkorstanje marked this pull request as draft March 9, 2022 00:59
JUnit 5 support is still anything but first class
(junit-team/junit5#2849). As such users
do need a quick and easy way to select feature files from the
commandline i.e:

```
mvn test -Dcucumber.features=path/to/example.feature
```

When enabled, other discovery selectors will be ignored. Of all
possible options is the least-worst solution. Additionally a
warning is logged prompting users to request better support. The
relevant issues to request/support/sponsor are:

 - IDEA
   - https://youtrack.jetbrains.com/issue/IDEA-227508
   - https://youtrack.jetbrains.com/issue/IDEA-276463
   - https://youtrack.jetbrains.com/issue/IDEA-276477

 - Eclipse
   -  No issue exists (yet).

 - Maven Surefire
   -  https://issues.apache.org/jira/browse/SUREFIRE-1724

 - Gradle
   - gradle/gradle#4773
@mpkorstanje mpkorstanje force-pushed the support-cucumber.features-property branch from 0b72aa2 to 946e6bc Compare March 9, 2022 01:03
@mpkorstanje mpkorstanje marked this pull request as ready for review March 11, 2022 11:03
@mpkorstanje mpkorstanje merged commit 52d9594 into main Mar 11, 2022
@mpkorstanje mpkorstanje deleted the support-cucumber.features-property branch March 11, 2022 11:38
mpkorstanje added a commit that referenced this pull request Dec 12, 2023
Maven Surefire and Gradle do not (yet?) fully support the JUnit
Platform API[1]. To work around this problem the `cucumber.features`
can be used.

However, because Maven Surefire and Gradle only attempt to discover
class based tests, they do expect a class source. As a result of this
missing source, Maven Surefire will not report on the executed tests
while Gradle reports the tests as having been executed by an
"Unknown Class".

By having the Cucumber TestEngine pretend to have a ClassSource when
`cucumber.features` is used both these problems go away.

1. #2498
mpkorstanje added a commit that referenced this pull request Dec 13, 2023
Maven Surefire and Gradle do not (yet?) fully support the JUnit
Platform API[1]. To work around this problem the `cucumber.features`
can be used.

However, because Maven Surefire and Gradle only attempt to discover
class based tests, they do expect a class source. As a result of this
missing source, Maven Surefire will not report on the executed tests
while Gradle reports the tests as having been executed by an
"Unknown Class".

By having the Cucumber TestEngine pretend to have a ClassSource when
`cucumber.features` is used both these problems go away.

1. #2498
mpkorstanje added a commit that referenced this pull request Dec 13, 2023
Maven Surefire and Gradle do not (yet?) fully support the JUnit
Platform API[1]. To work around this problem the `cucumber.features`
can be used.

However, because Maven Surefire and Gradle only attempt to discover
class based tests, they do expect a class source. As a result of this
missing source, Maven Surefire will not report on the executed tests
while Gradle reports the tests as having been executed by an
"Unknown Class".

By having the Cucumber TestEngine pretend to have a ClassSource when
`cucumber.features` is used both these problems go away.

1. #2498
mpkorstanje added a commit that referenced this pull request Dec 14, 2023
Maven Surefire and Gradle do not (yet?) fully support the JUnit
Platform API[1]. To work around this problem the `cucumber.features`
can be used.

However, because Maven Surefire and Gradle only attempt to discover
class based tests, they do expect a class source. As a result of this
missing source, Maven Surefire will not report on the executed tests
while Gradle reports the tests as having been executed by an
"Unknown Class".

By having the Cucumber TestEngine pretend to have a ClassSource when
`cucumber.features` is used both these problems go away.

1. #2498


Co-authored-by: Marit van Dijk <mlvandijk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants