Bird
Raised Fist0
Selenium Javatesting~20 mins

Report publishing in CI in Selenium Java - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
CI Report Publishing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Report Publishing in CI Pipelines

Which statement best describes the purpose of publishing test reports in a Continuous Integration (CI) pipeline?

ATo store test reports only on the local developer machine for privacy.
BTo automatically fix failed tests without developer intervention.
CTo prevent the CI pipeline from running if tests fail.
DTo provide a visual summary of test results accessible after each build to help developers quickly identify failures.
Attempts:
2 left
💡 Hint

Think about why teams want to see test results after every code change.

❓ Predict Output
intermediate
2:00remaining
TestNG Report Publishing Behavior in Jenkins

Given the following Jenkins pipeline snippet that runs TestNG tests and archives reports, what will be the outcome in Jenkins after the build completes?

Selenium Java
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn test'
      }
    }
    stage('Publish Report') {
      steps {
        junit 'target/surefire-reports/*.xml'
      }
    }
  }
}
AJenkins will archive the raw XML files but not display any test summary.
BJenkins will fail the build because the junit step requires HTML reports, not XML.
CJenkins will display a test report summary with passed, failed, and skipped tests after the build.
DJenkins will ignore the junit step and not publish any report.
Attempts:
2 left
💡 Hint

Consider what the junit step does with XML test reports.

❓ assertion
advanced
2:00remaining
Valid Assertion for Selenium Test Report Verification

Which assertion correctly verifies that the Selenium test report contains exactly 5 failed tests using Java and TestNG?

Selenium Java
int failedTests = report.getFailedTestCount();
AAssert.assertEquals(failedTests, 5);
BAssert.assertTrue(failedTests > 5);
CAssert.assertFalse(failedTests == 5);
DAssert.assertNull(failedTests);
Attempts:
2 left
💡 Hint

Think about how to check for exact equality in TestNG assertions.

🔧 Debug
advanced
2:00remaining
Debugging Missing Test Report in CI

A Selenium test suite runs successfully in Jenkins, but the test report is missing from the Jenkins UI. Which is the most likely cause?

AThe test report XML files were not generated or saved to the expected directory.
BThe Selenium tests did not run any assertions.
CThe test code uses deprecated Selenium APIs.
DThe Jenkins server is offline during the build.
Attempts:
2 left
💡 Hint

Think about what Jenkins needs to display reports.

❓ framework
expert
3:00remaining
Configuring Allure Report Publishing in a CI Pipeline

Which Jenkins pipeline snippet correctly runs Selenium tests with Maven and publishes Allure reports assuming Allure plugin is installed?

A
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn clean test'
      }
    }
    stage('Allure Report') {
      steps {
        archiveArtifacts 'target/allure-results/*'
      }
    }
  }
}
B
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn clean test'
      }
    }
    stage('Allure Report') {
      steps {
        allure includeProperties: false, jdk: '', results: [[path: 'target/allure-results']]
      }
    }
  }
}
C
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn clean test'
      }
    }
    stage('Allure Report') {
      steps {
        publishHTML(target: [reportDir: 'target/allure-results', reportFiles: 'index.html', reportName: 'Allure Report'])
      }
    }
  }
}
D
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn clean test'
      }
    }
    stage('Allure Report') {
      steps {
        junit 'target/allure-results/*.xml'
      }
    }
  }
}
Attempts:
2 left
💡 Hint

Recall the Jenkins Allure plugin syntax for publishing reports.

Practice

(1/5)
1. What is the main purpose of publishing test reports in a Continuous Integration (CI) pipeline?
easy
A. To increase the speed of test execution
B. To automatically fix failed tests
C. To reduce the number of test cases
D. To quickly show test results after code changes

Solution

  1. Step 1: Understand CI pipeline goals

    CI pipelines aim to integrate code changes frequently and provide feedback quickly.
  2. Step 2: Role of test reports in CI

    Publishing test reports helps teams see if tests passed or failed right after changes.
  3. Final Answer:

    To quickly show test results after code changes -> Option D
  4. Quick Check:

    Test reports in CI = Quick feedback [OK]
Hint: Test reports in CI = fast feedback on code changes [OK]
Common Mistakes:
  • Confusing report publishing with speeding up tests
  • Thinking reports reduce test cases
  • Believing reports fix tests automatically
2. Which of the following is the correct way to configure a Jenkins pipeline to publish JUnit test reports generated by Selenium Java tests?
easy
A. Use the junit '**/target/surefire-reports/*.xml' step in the pipeline script
B. Add publishJUnitReports() in the Java test code
C. Call driver.publishReports() in Selenium test methods
D. Use archiveArtifacts('**/*.html') to publish XML reports

Solution

  1. Step 1: Identify Jenkins syntax for JUnit reports

    Jenkins uses the junit step with a file pattern to locate XML reports.
  2. Step 2: Match correct usage

    junit '**/target/surefire-reports/*.xml' correctly points to JUnit XML files generated by Maven Surefire plugin.
  3. Final Answer:

    Use the junit '**/target/surefire-reports/*.xml' step in the pipeline script -> Option A
  4. Quick Check:

    Jenkins pipeline uses junit step with XML path [OK]
Hint: Jenkins publishes JUnit XML with junit('path') step [OK]
Common Mistakes:
  • Trying to publish reports from Java code directly
  • Using wrong Jenkins steps for report publishing
  • Archiving HTML instead of XML for JUnit reports
3. Given the following Jenkins pipeline snippet, what will be the result of the junit '**/target/surefire-reports/*.xml' step if no XML files are found?
pipeline {
  agent any
  stages {
    stage('Test') {
      steps {
        sh 'mvn test'
        junit '**/target/surefire-reports/*.xml'
      }
    }
  }
}
medium
A. The build will fail with an error about missing reports
B. The build will pass with no test results recorded
C. The build will retry the test stage automatically
D. The build will pass but mark tests as skipped

Solution

  1. Step 1: Understand junit step behavior with missing files

    If no XML files match, Jenkins does not fail the build but records no test results.
  2. Step 2: Confirm build status

    Since no test results are found, the build passes but shows zero tests executed.
  3. Final Answer:

    The build will pass with no test results recorded -> Option B
  4. Quick Check:

    No XML files = build passes, no tests recorded [OK]
Hint: No XML files found means no tests recorded, build still passes [OK]
Common Mistakes:
  • Assuming build fails if reports missing
  • Thinking tests are marked skipped automatically
  • Expecting automatic retries on missing reports
4. You configured your CI pipeline to publish Selenium test reports, but the reports are not visible in the CI dashboard. Which of the following is the most likely cause?
medium
A. The CI server does not support publishing reports
B. The Selenium tests did not run any assertions
C. The test report files are generated in a different directory than specified in the CI config
D. The test code uses deprecated Selenium APIs

Solution

  1. Step 1: Check report file paths in CI config

    If the CI pipeline looks for reports in the wrong folder, it won't find or display them.
  2. Step 2: Verify report generation location

    Ensure test reports are generated where the CI expects them, matching the configured path.
  3. Final Answer:

    The test report files are generated in a different directory than specified in the CI config -> Option C
  4. Quick Check:

    Report path mismatch = no reports shown [OK]
Hint: Check report file paths match between test and CI config [OK]
Common Mistakes:
  • Blaming test assertions for missing reports
  • Assuming CI server cannot publish reports
  • Thinking deprecated APIs affect report visibility
5. You want to publish Selenium Java test reports in a CI pipeline that uses GitHub Actions. Which combination of steps correctly collects and publishes the test results?
hard
A. Run tests with Maven, then use actions/upload-artifact to save reports, and configure actions/junit-report to display them
B. Run tests with Maven, then use actions/download-artifact to save reports, and actions/junit-report to display them
C. Run tests with Maven, then use actions/upload-artifact to save reports, and actions/upload-test-report to display them
D. Run tests with Maven, then use actions/upload-artifact to save reports, and no further steps are needed to display reports

Solution

  1. Step 1: Save test reports as artifacts

    Use actions/upload-artifact to store test report files after running tests.
  2. Step 2: Use a report action to display results

    Configure actions/junit-report or similar to parse and show test results in GitHub UI.
  3. Final Answer:

    Run tests with Maven, then use actions/upload-artifact to save reports, and configure actions/junit-report to display them -> Option A
  4. Quick Check:

    Upload artifact + report action = published test results [OK]
Hint: Upload reports artifact then use report action to display [OK]
Common Mistakes:
  • Using upload-test-report action which does not exist
  • Downloading artifacts instead of uploading
  • Skipping report display step after upload
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard