0
0
PyTesttesting~10 mins

Test result publishing 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 publish test results using pytest's command line option.

PyTest
pytest.main(['--[1]=result.xml'])
Drag options to blanks, or click blank then click option'
Averbose
Bhtml
Ccov
Djunitxml
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--html' instead of '--junitxml' to generate XML results.
Forgetting to specify the output file name.
2fill in blank
medium

Complete the code to import the pytest module needed for publishing test results.

PyTest
import [1]
Drag options to blanks, or click blank then click option'
Anose
Bpytest
Cunittest
Dmock
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'unittest' instead of 'pytest'.
Importing unrelated modules like 'mock'.
3fill in blank
hard

Fix the error in the code to correctly publish test results to an XML file.

PyTest
pytest.main(['--junitxml=[1]'])
Drag options to blanks, or click blank then click option'
Aoutput.log
Bresults.txt
Cresult.xml
Dreport.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using a text or HTML file extension instead of XML.
Using a file name without an extension.
4fill in blank
hard

Fill both blanks to create a pytest command that runs tests and publishes results in XML format.

PyTest
pytest.main(['[1]', '--[2]=test_results.xml'])
Drag options to blanks, or click blank then click option'
A-v
B-q
Cjunitxml
Dhtml
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-q' which is quiet mode instead of verbose.
Using '--html' instead of '--junitxml' for XML output.
5fill in blank
hard

Fill all three blanks to define a pytest test function and publish results to 'output.xml'.

PyTest
import pytest

def test_[1]():
    assert [2] == [3]

pytest.main(['--junitxml=output.xml'])
Drag options to blanks, or click blank then click option'
Aaddition
B2 + 2
C4
Dsubtraction
Attempts:
3 left
💡 Hint
Common Mistakes
Naming the test function without 'test_' prefix.
Using incorrect assertion values that fail the test.