-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce @ConfigurationParametersResource
for use with @Suite
classes
#3340
Comments
Fundamentally this problem is caused by a lack of first-class support for the JUnit Platform (#2849). In practice we are still dealing with JUnit 4 support with a translation layer bolted on for JUnit 5. This means that features such as selecting a line in a file for test execution using the file selector are simply not implemented by the popular IDEs and build systems. If you happen to use InteliJ IDEA it might help to upvote IDEA-227508.
This could also partially be resolved by the solutions outlined in cucumber/cucumber-jvm#2695. I have no immediate objections to this proposal but I do have a mild preference towards a solution in Cucumber rather than one in JUnit 5. I would also very much welcome a PR for cucumber/cucumber-jvm#2695. |
@ConfigurationParametersFile
for use with @Suite
classes
In general, I understand the desire to have such a feature. It could be beneficial not only for use with For example, we could consider introducing
If a solution tailored to Cucumber can be implemented, that would likely be ideal. However, as stated above, I think having the ability to provide a "file" as a source for configuration parameters could be beneficial and would help alleviate duplication of configuration.
You mean a PR for the Cucumber project? |
Yes. Edited for clarity.
Do you think that there are use cases for file based configuration outside of this specific example? If Cucumber was not involved, I reckon most of these hypothetical use cases could be addressed by using That said, again, I don't have any immediate objection to this feature proposal on its own. It would in fact smooth over a problem that Cucumber users have. Though do think that it solves the underlying problem (a lack of support) in the wrong location. |
Team decision: Introduce |
@robinjhector Would you be interested in submitting a PR for this? |
Sure thing! I'll give it a go :) |
This commit adds support for specifying a properties file, for use with configuration parameters. - Added a new field configurationParametersResources of type List<String> to store the configuration parameters resources. - Added new methods configurationParametersResource(String propertiesFile) and configurationParametersResources(List<String> propertiesFiles) to add configuration parameters resources to the request builder. - Updated the buildLauncherConfigurationParameters() method to include the configurationParametersResources in the Builder instance. Related to issue: junit-team#3340
This commit adds support for specifying a properties file, for use with configuration parameters. - Added a new field configurationParametersResources of type List<String> to store the configuration parameters resources. - Added new methods configurationParametersResource(String propertiesFile) and configurationParametersResources(List<String> propertiesFiles) to add configuration parameters resources to the request builder. - Updated the buildLauncherConfigurationParameters() method to include the configurationParametersResources in the Builder instance. Related to issue: junit-team#3340
This commit adds support for specifying a properties file, for use with configuration parameters. - Added a new field configurationParametersResources of type List<String> to store the configuration parameters resources. - Added new methods configurationParametersResource(String propertiesFile) and configurationParametersResources(List<String> propertiesFiles) to add configuration parameters resources to the request builder. - Updated the buildLauncherConfigurationParameters() method to include the configurationParametersResources in the Builder instance. Related to issue: junit-team#3340
I made a PR: #3345 |
Hi @mpkorstanje,
Thanks
Yes. Teams may have more than one "test" task in their build -- for example, one for unit tests and one for integration tests, etc. In such scenarios, it is impossible to have multiple Furthermore, with this feature one could still have a core |
@ConfigurationParametersFile
for use with @Suite
classes@ConfigurationParametersResource
for use with @Suite
classes
This commit adds support for specifying a properties file, for use with configuration parameters. - Added a new field configurationParametersResources of type List<String> to store the configuration parameters resources. - Added new methods configurationParametersResource(String propertiesFile) and configurationParametersResources(List<String> propertiesFiles) to add configuration parameters resources to the request builder. - Updated the buildLauncherConfigurationParameters() method to include the configurationParametersResources in the Builder instance. Related to issue: junit-team#3340
Introduce `@ConfigurationParametersResource` for `@Suite` classes and `--config-resource` option for ConsoleLauncher that allow specifying additional properties files on the classpath as sources of configuration parameters. Resolves #3340. Co-authored-by: Marc Philipp <mail@marcphilipp.de>
(This issue will describe my problems using JUnit together with another engine: Cucumber. But hopefully the proposed solution would increase JUnit Suite usability overall)
According to the documentation. the preferred way of running Cucumber, is via the JUnit Platform Suite.
I can set configuration parameters for the suite launcher discovery request, which then the underlaying engine can use, via
@ConfigurationParameter
, or@ConfigurationParameters
.It also defaults to parsing a
junit-platform.properties
file on classpath if found.As long as I have set my configuration parameters as described above, the cucumber engine boots nicely, and everything works as expected.
However, when running Cucumber on the CLI, or via my IDE´s "run" functionality, Cucumber is not run via the the JUnit platform.
This makes configuring my tests to work with both JUnit and in standalone mode a bit tricky. Cucumber, in standalone mode, will try and look for a
cucumber.properties
file on classpath.So I have a few options:
junit-platform.properties
file, and save it ascucumber.properties
.(Sad, keeping two files in sync is always a pain)
cucumber.properties
file, and use annotations for the JUnit Suite (@ConfigurationParameter
)(Same here, I will have some configuration in-code, and some in a properties file)
(I dislike it because it requires environmental setup for new developers, and may cause system-system variances)
Instead, it would be super helpful if we could feed configuration parameters to the JUnit Platform Suite, from a properties file of choice. If so I could have a single properties file for both my standalone cucumber runs, and my platform suite runs.
Suggestion
My idea is to introduce a new annotation, like:
(Naming tbd..)
Which would work just like
@ConfigurationParameter
, by reading the file and setting the config parameters.Annotating with both
@ConfigurationParameterFile
and@ConfigurationParameter
should be allowed. Where as@ConfigurationParameter
takes precedence for a given key-value.Deliverables
SuiteLauncherDiscoveryRequestBuilder
to parse the properties file, as specified in the new annotationI'd be happy to take a stab at implementing this via a PR.
Feedback always welcome. Hope my points came across clearly, otherwise please let me know!
The text was updated successfully, but these errors were encountered: