As an automation tester I want to execute our automation test script in parallel. So I can finish the execution faster.
Prerequisite
Our automation test script need to config to execute with Junit 5
Configuration
There are atleast two ways to configure the test cases can run in parallel is using configuration file and using annotation.
Configure with configuration file
To run our script in parallel we can create junit-platform.properties
file in src/java/resources
folder and create the content with
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent
The above content will enable the parallel executing feature and make script can run functions and classes in parallel. For more details, we can run with fix number of thread is 2 (We can change to any number).
//To execute test with fix number of thread
junit.jupiter.execution.parallel.config.strategy=fixed
junit.jupiter.execution.parallel.config.fixed.parallelism=2
Configure directly by annotation
We can define the class or function is run with concurrent or same thread with annotation
//To execute class/function in concurrent mode
@Execution(ExecutionMode.CONCURRENT)
//To execute class/function in same thread mode
@Execution(ExecutionMode.SAME_THREAD)
For more information
Example
Source code is here withhow_to_assert_two_list_with_assertj
feature folder that contains test cases are configured by annotation.