0
0
PyTesttesting~10 mins

JUnit XML reporting for CI in PyTest - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run pytest and generate a JUnit XML report named 'results.xml'.

PyTest
import pytest

pytest.main(['tests', '--junitxml=[1]'])
Drag options to blanks, or click blank then click option'
Aresults.xml
Boutput.txt
Creport.json
Dlog.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using a filename with wrong extension like '.txt' or '.json'.
Forgetting to include the '--junitxml' option.
2fill in blank
medium

Complete the pytest command to run tests in the 'integration' folder and output JUnit XML report to 'ci_report.xml'.

PyTest
pytest.main(['[1]', '--junitxml=ci_report.xml'])
Drag options to blanks, or click blank then click option'
Atests
Bunit
Ce2e
Dintegration
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong folder name like 'unit' or 'tests'.
Omitting the folder argument causing all tests to run.
3fill in blank
hard

Fix the error in the pytest command to correctly generate a JUnit XML report named 'test-results.xml'.

PyTest
pytest.main(['tests', '--junitxml', '[1]'])
Drag options to blanks, or click blank then click option'
Atest-results.xml
Btest-results.txt
C--junitxml=test-results.xml
Dresults.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Passing '--junitxml=test-results.xml' as a separate argument causes error.
Using wrong file extension like '.txt'.
4fill in blank
hard

Fill both blanks to create a pytest command that runs tests in 'api_tests' folder and saves JUnit XML report as 'api_report.xml'.

PyTest
pytest.main(['[1]', '[2]'])
Drag options to blanks, or click blank then click option'
Aapi_tests
B--junitxml=api_report.xml
Ctests
D--junitxml=report.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up folder and option arguments.
Using wrong filenames or folder names.
5fill in blank
hard

Fill all three blanks to create a pytest command that runs tests in 'ui_tests', outputs JUnit XML report to 'ui_results.xml', and increases verbosity.

PyTest
pytest.main(['[1]', '[2]', '[3]'])
Drag options to blanks, or click blank then click option'
Aui_tests
B--junitxml=ui_results.xml
C-v
D--maxfail=1
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--maxfail=1' instead of '-v' for verbosity.
Wrong order of arguments causing errors.