Framework Mode - JUnit XML reporting for CI
Folder Structure
project-root/ ├── tests/ │ ├── test_example.py │ └── test_login.py ├── reports/ │ └── junit-report.xml ├── conftest.py ├── pytest.ini └── requirements.txt
Jump into concepts and practice - no test required
project-root/ ├── tests/ │ ├── test_example.py │ └── test_login.py ├── reports/ │ └── junit-report.xml ├── conftest.py ├── pytest.ini └── requirements.txt
tests/ folder, contains test scripts like test_example.py.conftest.py holds reusable setup/teardown code and fixtures.reports/ folder stores generated JUnit XML reports for CI consumption.pytest.ini configures pytest options including JUnit XML output.requirements.txt lists Python packages like pytest.Use pytest.ini to configure JUnit XML reporting and other options:
[pytest] addopts = --junitxml=reports/junit-report.xml
This tells pytest to generate a JUnit XML report in the reports/ folder after tests run.
For environment-specific settings (like test URLs or credentials), use environment variables or separate config files loaded in conftest.py.
reports/junit-report.xml) is a standard format understood by most CI tools (Jenkins, GitHub Actions, GitLab CI).pytest with the configured --junitxml option to generate the report.reports/ folder to separate outputs from source code.pytest.ini or command-line options to control report generation consistently.Where in this folder structure would you add a new test file for user registration?
results.xml?--junitxml=filename.--junitxml=results.xml, which is correct syntax.pytest tests/ --junitxml=report.xmltests/ folder and generates a JUnit XML report file named report.xml.--junitxml=report.xml is specified, the file will be created with test results in XML format.pytest --junitxml=results.xml but the file results.xml is empty. What is the most likely cause?--junitxml is correct, pytest supports it, and invalid paths usually cause errors, not silent empty files.ci-report.xml. Which command should you use?--failfast and limit failures with --maxfail=1.--junitxml=ci-report.xml saves the report file as required.--junitxml=ci-report.xml, --failfast, and --maxfail=1. Others have wrong or conflicting flags.