Reputation: 103
I'm using Cucumber 5, Junit 5. I have written tests in feature-files.
Now I would like to do this:
Please tell me how this can be done on Cucumber5/Junit5 ?
Upvotes: 0
Views: 1010
Reputation: 12019
Rather then thinking in groups of tests you should identify the resource(s) that should not be used concurrently. Once you've identified these resources you tag each scenario or with the resources that they use. You can tag all scenarios in a feature file by tagging the feature.
Then you can configure Cucumber to instruct the JUnit Platform to avoid scheduling these scenarios concurrently via junit-platform.properties
:
cucumber.execution.exclusive-resources.<tag-name>.read-write=<resource-name>
For example when using:
cucumber.execution.exclusive-resources.reads-and-writes-system-properties.read-write=SYSTEM_PROPERTIES
A scenario tagged with @reads-and-writes-system-properties
will lock the SYSTEM_PROPERTIES
resource with a read-write lock and will not be concurrently executed with any other scenarios that lock the same resource.
See: https://github.com/cucumber/cucumber-jvm/tree/main/junit-platform-engine#exclusive-resources
Upvotes: 1