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

Document @ConfigurationParametersResource as a means to avoid duplicating cucumber.properties #2695

Open
mpkorstanje opened this issue Feb 24, 2023 · 5 comments
Assignees
Labels
📖 documentation Improvements or additions to documentation

Comments

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Feb 24, 2023

🤔 What's the problem you're trying to solve?

When launched through io.cucumber.core.cli.Main Cucumber will use cucumber.properties. When launched through the JUnit Platform the junit-platform.properties file is used.

This difference can be confusing for novice and advanced users who use Intelij IDEA. And unfortunately JetBrains has made little progres improving on this (see IDEA-227508).

✨ What's your proposed solution?

Create a new main method that maps the CLI arguments to the JUnit Platform and runs Cucumber. This main can then be used in IDEAs run configuration.

⛏ Have you considered any alternatives or workarounds?

Reading cucumber.properties in the JUnit Platform is an option. Though because Cucumber and JUnit have different semantics around merging properties this doesn't seem feasible.

Alternatively Cucumber could change it's property reading mechanism to be more sane. But that would be something for the next major release.

Or I could implement a better Cucumber plugin. Though I should probably do it in VS Code. Maybe that will get JetBrains attention. My subscription certainly doesn't.

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented Jun 5, 2023

Additional idea. Consider adding a --junit-platform flag or subcommand to the regular CLI that will delegate to the JUnit Platform for reduced friction.

@jkronegg
Copy link
Contributor

The workaround is to have the two files cucumber.properties and junit-platform.properties with the same content, so that Cucumber runtime configuration is the same no matter the execution method.

@mpkorstanje
Copy link
Contributor Author

Thanks for reminding me. There's a better workaround now. It allows the properties to be shared.

https://github.com/junit-team/junit5/blob/main/junit-platform-suite-api/src/main/java/org/junit/platform/suite/api/ConfigurationParametersResource.java

@jkronegg
Copy link
Contributor

I added @ConfigurationParametersResource("cucumber.properties") and it works. To summarize the different behaviors:

Run with cucumber.properties +
@ConfigurationParametersResource("cucumber.properties")
on Cucumber test class
cucumber.properties +
same junit-platform.properties
cucumber.properties only
IntelliJ IDEA right click on project,
Run "All tests"
(or right click on Cucumber test class,
then Run "<testClass>")
properties taken into account properties taken into account ⚠️properties not taken into account
IntelliJ IDEA right click on the project
Run "All Features in: <project>"
properties taken into account
(but all features are ran twice)
properties taken into account
(but all features are ran twice)
properties taken into account
(but all features are ran twice)
IntelliJ IDEA right click on the resource
directory which contains the feature files,
Run "All Features in: <directory>"
properties taken into account properties taken into account properties taken into account
Maven running Cucumber test class properties taken into account properties taken into account properties taken into account

I still didn't found why the features files are ran twice when using Intellij's "Run All Features in <project>", but that's another story...

@mpkorstanje
Copy link
Contributor Author

I still didn't found why the features files are ran twice when using Intellij's "Run All Features in ", but that's another story...

Sounds like IDEA is using the class path root selector on the JUnit Platform. It will discover both the Suite through the Suite Engine and the features through the Cucumber Engine.

@mpkorstanje mpkorstanje self-assigned this Feb 9, 2025
@mpkorstanje mpkorstanje added 📖 documentation Improvements or additions to documentation and removed ⚡ enhancement Request for new functionality labels Feb 9, 2025
@mpkorstanje mpkorstanje changed the title A separate main to launch JUnit Platform Document @ConfigurationParametersResource as a means to avoid duplicating cucumber.properties Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants