I want to run feature files parallelly in alphabetical order and scenarios of each feature file in serial order. I am using JUnit 5 configurations to run the test in parallel. Basically want to use junit 5 built in mechanism to run feature file parallel and not sceanrios and feature file should be executed in alphabetical order like it used to work with junit 4 and surefire plugin
Asked
Active
Viewed 208 times
1 Answers
0
You can not. Scenarios are intended to be executed independently from each other. It was a limitation of JUnit 4 that only features were run in parallel.
Depending on what you are testing, you could turn all scenarios in a feature file into a single scenario.
However you should consider rewriting your scenarios such that they do not depend on the actions in previous scenarios.
Typically this means writing scenarios like:
Scenario: Do a thing
Given a thing
When a thing is used
Then something happens
Scenario: Do another thing next
Given a thing that was used
When a thing is used again
Then something else happens
To implement a thing that was used
you can reuse the methods you've already written to implement the steps of the first scenario.

M.P. Korstanje
- 10,426
- 3
- 36
- 58
-
Okay...and how to decide the order of feature file such that it runs alphabetically – Aayush Grover May 02 '22 at 07:15
-
Do you understand what parallel execution means? – M.P. Korstanje May 02 '22 at 07:43
-
I mean in cucumber by default it is set to run alphabetically but I am not getting why it's not running in parallel with same order – Aayush Grover May 02 '22 at 10:09
-
Imagine a group of people. They're walking into a building one after another. You can tell them to walk into the building in alphabetical order of their last name. – M.P. Korstanje May 02 '22 at 11:07
-
Now imagine the same group of people standing next to each other against a wall. Then when the start signal comes they all at the same time start sprinting to the other side of the room. You can't tell them to run in any order because they're all running concurrently. – M.P. Korstanje May 02 '22 at 11:10
-
Okay got your point....so is there any way to fix one feature file to execute at the end of the program or get executed before all other feature files starts it execution – Aayush Grover May 03 '22 at 16:15
-
If you have a recent version of Cucumber you have BeforeAll and AfterAll hooks. Can't run features in them but you can do stuff there. – M.P. Korstanje May 03 '22 at 17:02