0
0
PyTesttesting~10 mins

Running PyTest in Jenkins - 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 in a Jenkins pipeline step.

PyTest
sh 'pytest [1]'
Drag options to blanks, or click blank then click option'
A--verbose
B--help
C--version
D--list
Attempts:
3 left
💡 Hint
Common Mistakes
Using --help shows help text but does not run tests.
Using --version only shows PyTest version.
Using --list is not a valid PyTest option.
2fill in blank
medium

Complete the Jenkinsfile step to archive PyTest test reports.

PyTest
archiveArtifacts artifacts: '[1]', fingerprint: true
Drag options to blanks, or click blank then click option'
A**/output.txt
B**/test-results.xml
C**/pytest.log
D**/coverage.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Archiving log files instead of test result XML.
Using coverage report file which is different from test results.
3fill in blank
hard

Fix the error in the Jenkins pipeline command to run PyTest with junitxml output.

PyTest
sh 'pytest --junitxml=[1]'
Drag options to blanks, or click blank then click option'
Aresults
Bresults.json
Cresults.txt
Dresults.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using a filename without extension causes PyTest to error.
Using .txt or .json extensions is invalid for junitxml.
4fill in blank
hard

Fill both blanks to run PyTest only on files in the tests directory and generate XML report.

PyTest
sh 'pytest [1] --junitxml=[2]'
Drag options to blanks, or click blank then click option'
Atests/
Btest/
Creport.xml
Dresults.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong folder name like 'test/' if tests are in 'tests/'.
Using a non-XML file name for the report.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline step that runs PyTest with verbose output, saves XML report, and archives it.

PyTest
sh 'pytest [1] --junitxml=[2]'
archiveArtifacts artifacts: '[3]', fingerprint: true
Drag options to blanks, or click blank then click option'
A--verbose
Bresults.xml
C**/results.xml
D--quiet
Attempts:
3 left
💡 Hint
Common Mistakes
Using --quiet instead of --verbose loses detailed logs.
Archiving wrong file pattern causes no files to be saved.