0
0
Jenkinsdevops~10 mins

Parallel test execution in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Parallel test execution
Start Jenkins Pipeline
Define parallel stages
Trigger tests in parallel
Wait for all tests to finish
Collect and report results
End
The Jenkins pipeline starts, defines multiple test stages to run at the same time, waits for all to finish, then collects results.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    stage('Parallel Tests') {
      parallel {
        'Test A': {
          steps { echo 'Running Test A' }
        },
        'Test B': {
          steps { echo 'Running Test B' }
        }
      }
    }
  }
}
This Jenkins pipeline runs two test stages, Test A and Test B, at the same time.
Process Table
StepActionStage RunningOutputNotes
1Start pipelineNonePipeline startedPipeline begins execution
2Enter 'Parallel Tests' stageNoneEntering parallel blockPrepare to run parallel stages
3Start 'Test A' stageTest ARunning Test ATest A runs independently
4Start 'Test B' stageTest BRunning Test BTest B runs independently
5Wait for 'Test A' and 'Test B' to finishTest A, Test BBoth tests completeParallel stages complete
6Collect resultsNoneResults collectedPipeline gathers test outputs
7End pipelineNonePipeline finishedPipeline execution ends
💡 All parallel test stages complete, pipeline finishes.
Status Tracker
VariableStartAfter Step 3After Step 4After Step 5Final
Stage RunningNoneTest ATest A, Test BNoneNone
OutputPipeline startedRunning Test ARunning Test A, Running Test BBoth tests completePipeline finished
Key Moments - 2 Insights
Why do 'Test A' and 'Test B' run at the same time instead of one after the other?
Because they are defined inside the 'parallel' block (see execution_table steps 3 and 4), Jenkins runs these stages simultaneously to save time.
What happens if one parallel test fails?
The pipeline waits for all parallel stages to finish (step 5), but the overall pipeline may fail depending on the test results. This ensures all tests complete before reporting.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step do both 'Test A' and 'Test B' run simultaneously?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Check the 'Stage Running' column in steps 3 and 4 to see when both tests are active.
According to the variable tracker, what is the value of 'Stage Running' after step 4?
ANone
BTest A
CTest A, Test B
DTest B
💡 Hint
Look at the 'Stage Running' row in variable_tracker after step 4.
If we remove the 'parallel' block and run tests sequentially, how would the execution table change?
AThere would be no 'Parallel Tests' stage.
BSteps 3 and 4 would run one after another, not simultaneously.
CSteps 3 and 4 would still run at the same time.
DThe pipeline would skip tests.
💡 Hint
Parallel block controls simultaneous execution; removing it causes sequential runs.
Concept Snapshot
Jenkins Parallel Test Execution:
- Use 'parallel' block inside a stage to run multiple tests at once.
- Each test runs independently, saving time.
- Pipeline waits for all parallel tests to finish before continuing.
- Useful for speeding up test suites in CI pipelines.
Full Transcript
This visual execution shows how Jenkins runs tests in parallel. The pipeline starts, then enters a stage with a parallel block. Inside, Test A and Test B start at the same time. Jenkins waits for both to finish, then collects results and ends the pipeline. Variables track which stages run and outputs at each step. Key points include understanding that parallel stages run simultaneously and the pipeline waits for all to complete before moving on. The quiz checks understanding of when tests run together and how removing parallel changes execution.