cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

Improve the cucumber.features warning #2852

Closed mpkorstanje closed 7 months ago

mpkorstanje commented 7 months ago

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

In https://github.com/cucumber/cucumber-jvm/pull/2498 I added support for selecting features through a CLI. This included a warning to dissuade people from using it.

io.cucumber.junit.platform.engine.DiscoverySelectorResolver warnWhenCucumberFeaturesPropertyIsUsed WARNING: Discovering tests using the cucumber.features property. Other discovery selectors are ignored! Please request/upvote/sponsor/ect better support for JUnit 5 discovery selectors. See: https://github.com/cucumber/cucumber-jvm/pull/2498

This warning works well when used in the intended context. I.e. mvn test -Dcucumber.features=path/to/example.feature

But somehow it ends up being used outside of that intended purpose. E.g:

And is not clear to me what prompts people to do this in the first place. All documentation examples use the @SelectClasspathResource to select features.

Anyway, once emitted in the wrong context the warning is pretty confusing. It doesn't tell people what they're doing wrong. Or how to remedy the situation. It just makes them think stuff is broken.

And while it does mention "discovery selectors" this is a JUnit 5 API term that probably doesn't mean much to most people. I doubt people would connect it to the @SelectClasspathResource annotation or the @Suite class.

✨ What's your proposed solution?

Rewrite the warning to more clearly inform people that for normal use they should use JUnits Suite annotations.

⛏ Have you considered any alternatives or workarounds?

The PR https://github.com/cucumber/cucumber-jvm/pull/2498 linked from the warning already includes a note that users should use the JUnit annotations but it seems to go ignored.

Perhaps that explanation can be expanded?