Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a filename with wrong extension like '.txt' or '.json'.
Forgetting to include the '--junitxml' option.
✗ Incorrect
The '--junitxml' option tells pytest to save the test results in JUnit XML format. The filename should be 'results.xml' to match the requirement.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong folder name like 'unit' or 'tests'.
Omitting the folder argument causing all tests to run.
✗ Incorrect
The argument specifies the folder where tests are located. Here, 'integration' is the correct folder to run integration tests.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing '--junitxml=test-results.xml' as a separate argument causes error.
Using wrong file extension like '.txt'.
✗ Incorrect
When using '--junitxml' as a separate argument, the next argument must be the filename. So 'test-results.xml' is correct here.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up folder and option arguments.
Using wrong filenames or folder names.
✗ Incorrect
The first argument is the folder 'api_tests' to run tests from. The second argument is the option '--junitxml=api_report.xml' to save the report.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--maxfail=1' instead of '-v' for verbosity.
Wrong order of arguments causing errors.
✗ Incorrect
The command runs tests in 'ui_tests', saves the report to 'ui_results.xml', and uses '-v' for verbose output.