0
0
JUnittesting~20 mins

CI pipeline test stage in JUnit - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
JUnit CI Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of a JUnit test run in CI pipeline
What is the output of this JUnit test run command in a CI pipeline when all tests pass?
JUnit
mvn test
A[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0
B[WARNING] Tests run: 10, Failures: 0, Errors: 1, Skipped: 0
C[ERROR] Tests run: 10, Failures: 1, Errors: 0, Skipped: 0
D[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 2
Attempts:
2 left
💡 Hint
Look for zero failures and errors in the test summary.
Configuration
intermediate
2:00remaining
JUnit test stage configuration in Jenkinsfile
Which Jenkinsfile snippet correctly defines a test stage that runs JUnit tests and archives the results?
A
stage('Test') {
  steps {
    sh 'mvn test'
    junit '**/target/surefire-reports/*.xml'
  }
}
B
stage('Test') {
  steps {
    sh 'mvn compile'
    junit '**/target/surefire-reports/*.xml'
  }
}
C
stage('Test') {
  steps {
    sh 'mvn test'
    archiveArtifacts '**/target/surefire-reports/*.xml'
  }
}
D
stage('Test') {
  steps {
    sh 'mvn test'
    junit '**/target/junit-reports/*.xml'
  }
}
Attempts:
2 left
💡 Hint
JUnit plugin expects test report XML files in surefire-reports directory.
Troubleshoot
advanced
2:00remaining
Diagnosing JUnit test failures in CI pipeline
A CI pipeline test stage running JUnit tests fails with this error: "No tests found". What is the most likely cause?
AThe test reports are archived before tests run.
BThe JUnit plugin is not installed in the CI server.
CThe source code has compilation errors preventing tests from running.
DThe test classes are not named according to the pattern recognized by the test runner.
Attempts:
2 left
💡 Hint
JUnit looks for test classes with specific naming conventions.
🔀 Workflow
advanced
2:00remaining
Correct order of steps in a CI pipeline test stage
What is the correct order of steps in a CI pipeline test stage using JUnit?
A1,3,2,4
B1,4,2,3
C2,1,3,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Tests must run and fail the build before archiving and publishing results.
Best Practice
expert
2:00remaining
Best practice for handling flaky JUnit tests in CI pipeline
Which approach is best to handle flaky JUnit tests in a CI pipeline test stage?
ARun flaky tests only locally and never in the CI pipeline
BIgnore test failures and always mark the build as successful
CAutomatically retry failed tests a limited number of times before marking the build failed
DRemove flaky tests from the test suite permanently
Attempts:
2 left
💡 Hint
Flaky tests should be retried to reduce false negatives but not ignored.