🤔 What's the problem you're trying to solve?
We have multiple test cases that can be divided neatly into three parts:
- Initial setup/precondition that needs to be executed once
- Performing a series of transactions that are independent of each other
- Generating a report which contains details of each transaction that then need to be validated
Steps 1 and 3 need to run exactly once, before and after step 2. The individual transaction operations of Step 2 can be run in parallel at the same time.
Presently we just have steps 1 and 3 as individual scenarios and then step 2 as multiple different scenarios. All these scenarios execute in sequential order.
Steps 1 and 3 cannot be executed per scenario of step 2 as steps 1 and 3 change the state of the application being tested. Steps 1 and 3 also cannot be put in a @BeforeAll and @AfterAll hook as that'll affect the execution of other test cases that do not require Steps 1 and 3.
Thus, it is not possible to run these types of test cases in parallel.
✨ What's your proposed solution?
Support the same type of conditional execution present in @Before and @After hooks by using tags within @BeforeAll and @AfterAll hooks.
⛏ Have you considered any alternatives or workarounds?
We can use an AtomicBoolean alongside a simple if statement inside a tagged @Before hook and ensure that only one thread runs the required code.
For operations that need to be in @After hooks, it'll be a bit more difficult - we'd have to add a piece of code to each scenario running in parallel to confirm that they have finished execution, and only when all required scenarios have reached completion, execute the code in the @After hook.
Both of these solutions might work, but it feels like an unnecessary complexity.
📚 Any additional context?
No response
🤔 What's the problem you're trying to solve?
We have multiple test cases that can be divided neatly into three parts:
Steps 1 and 3 need to run exactly once, before and after step 2. The individual transaction operations of Step 2 can be run in parallel at the same time.
Presently we just have steps 1 and 3 as individual scenarios and then step 2 as multiple different scenarios. All these scenarios execute in sequential order.
Steps 1 and 3 cannot be executed per scenario of step 2 as steps 1 and 3 change the state of the application being tested. Steps 1 and 3 also cannot be put in a
@BeforeAlland@AfterAllhook as that'll affect the execution of other test cases that do not require Steps 1 and 3.Thus, it is not possible to run these types of test cases in parallel.
✨ What's your proposed solution?
Support the same type of conditional execution present in
@Beforeand@Afterhooks by using tags within@BeforeAlland@AfterAllhooks.⛏ Have you considered any alternatives or workarounds?
We can use an
AtomicBooleanalongside a simple if statement inside a tagged@Beforehook and ensure that only one thread runs the required code.For operations that need to be in
@Afterhooks, it'll be a bit more difficult - we'd have to add a piece of code to each scenario running in parallel to confirm that they have finished execution, and only when all required scenarios have reached completion, execute the code in the@Afterhook.Both of these solutions might work, but it feels like an unnecessary complexity.
📚 Any additional context?
No response