Recall & Review
beginner
What is the purpose of running unit tests in a Jenkins pipeline?
Running unit tests in a Jenkins pipeline helps catch code errors early by automatically checking if small parts of the code work correctly before moving forward.
Click to reveal answer
beginner
Which Jenkins pipeline step is commonly used to run shell commands like unit tests?
The
sh step is used to run shell commands, such as executing unit test scripts or commands in a Jenkins pipeline.Click to reveal answer
intermediate
How do you fail a Jenkins pipeline if unit tests fail?
If the unit test command returns a non-zero exit code, Jenkins marks the pipeline as failed automatically, stopping further steps.
Click to reveal answer
beginner
What is the benefit of using a 'stage' for unit tests in a Jenkins pipeline?
Using a separate 'stage' for unit tests organizes the pipeline clearly, making it easy to see test results and isolate test failures.
Click to reveal answer
beginner
Show a simple Jenkins pipeline snippet that runs unit tests using a shell command.
pipeline {
agent any
stages {
stage('Unit Tests') {
steps {
sh 'python -m unittest discover'
}
}
}
}Click to reveal answer
What happens if unit tests fail in a Jenkins pipeline stage?
✗ Incorrect
If unit tests fail (non-zero exit code), Jenkins marks the stage as failed and stops the pipeline unless configured otherwise.
Which Jenkins pipeline syntax is used to run a shell command?
✗ Incorrect
The
sh step runs shell commands in Jenkins pipelines.Why is it good practice to have a separate stage for unit tests in Jenkins?
✗ Incorrect
Separating unit tests into their own stage helps organize the pipeline and makes test results easy to find.
What command might you use in a Jenkins pipeline to run Python unit tests?
✗ Incorrect
The command
python -m unittest discover runs Python unit tests.In Jenkins, what does a non-zero exit code from a test command indicate?
✗ Incorrect
A non-zero exit code means the command failed, indicating test failures.
Explain how to add unit tests to a Jenkins pipeline and what happens if tests fail.
Think about pipeline stages and shell commands.
You got /3 concepts.
Describe the benefits of running unit tests automatically in a Jenkins pipeline.
Consider how automation helps in software quality.
You got /3 concepts.