Test reporting in CI helps you see if your tests passed or failed automatically after every code change. It makes sure your software stays good without checking manually.
Test reporting in CI in Selenium Python
pytest --junitxml=report.xml
# Then configure your CI tool to run this command and collect report.xmlThe --junitxml option creates a test report file in XML format.
CI tools like Jenkins or GitHub Actions can read this file to show test results.
results.xml.pytest --junitxml=results.xml
tests/ folder and saves the report as ci_report.xml.pytest tests/ --junitxml=ci_report.xml
This script opens Google in Chrome, checks the page title, and quits the browser. It runs the test with pytest and saves the report as report.xml.
from selenium import webdriver import pytest def test_google_title(): driver = webdriver.Chrome() driver.get('https://www.google.com') assert 'Google' in driver.title driver.quit() if __name__ == '__main__': pytest.main(['--junitxml=report.xml'])
Make sure your CI environment has the browser driver installed for Selenium tests.
Use meaningful test names so reports are easy to understand.
Keep reports in a folder your CI tool can access and archive them if needed.
Test reporting in CI gives quick feedback on test results automatically.
Use pytest with --junitxml to create reports CI tools can read.
Reports help teams find and fix problems faster.
Practice
Solution
Step 1: Understand CI test reporting role
Test reporting in CI is designed to give fast feedback on whether tests pass or fail after code changes.Step 2: Identify the correct purpose
Among the options, only providing quick automatic feedback matches the main purpose of test reporting in CI.Final Answer:
To provide quick feedback on test results automatically -> Option AQuick Check:
Test reporting = quick feedback [OK]
- Confusing test reporting with deployment
- Thinking test reporting is about writing tests
- Mixing test reporting with documentation
Solution
Step 1: Recall pytest report options
Pytest uses--junitxmlto create XML reports compatible with many CI tools.Step 2: Match option to XML report
Among the options, only--junitxml=report.xmlgenerates the correct XML format for CI.Final Answer:
--junitxml=report.xml -> Option BQuick Check:
Pytest XML report = --junitxml [OK]
- Using --html instead of --junitxml
- Confusing JSON or text output with XML
- Missing the file name after the option
pytest tests/ --junitxml=results.xmlWhat will happen after the tests run?
Solution
Step 1: Understand the command effect
The--junitxml=results.xmloption tells pytest to save test results in XML format to the file named results.xml.Step 2: Identify the output file type
The file created is XML, not HTML, and the command syntax is correct, so tests run and report is saved.Final Answer:
A file named results.xml will be created with test results in XML format -> Option CQuick Check:
--junitxml creates XML report file [OK]
- Thinking no report is created
- Confusing XML with HTML report
- Assuming command syntax error
--junitxml=report.xml to your pytest command, but the CI tool shows no test report. What is the most likely cause?Solution
Step 1: Check report file location
CI tools need the report file in the workspace folder to read it. If saved elsewhere, the tool won't find it.Step 2: Verify other causes
The command syntax is correct, tests likely ran, and most CI tools support XML reports, so the missing file location is the main issue.Final Answer:
The report.xml file is not saved in the CI workspace directory -> Option DQuick Check:
Report file location matters in CI [OK]
- Assuming command syntax error without checking
- Ignoring file save location
- Thinking CI tools don't support XML reports
Solution
Step 1: Generate machine-readable test report
Using--junitxml=report.xmlcreates a detailed XML report that CI tools can parse.Step 2: Configure CI to fail build on test failures
CI tools can read the XML report and mark the build as failed if tests fail, automating quality checks.Final Answer:
Run pytest with --junitxml=report.xml and configure CI to fail on test failures using this report -> Option AQuick Check:
Use XML report + CI fail on test fail [OK]
- Ignoring test failures in CI
- Not generating machine-readable reports
- Relying on manual log checks
Ready to prove it?
Pass the test and this pattern moves unknown
