Pytest fails to generate junitxml report with captured stdout after pytest 5.4.0.
Package Version
------------------ -------
apipkg 1.5
atomicwrites 1.3.0
attrs 19.3.0
execnet 1.7.1
filelock 3.0.12
importlib-metadata 1.5.0
more-itertools 8.2.0
packaging 20.3
pip 20.0.2
pluggy 0.13.1
py 1.8.1
pyparsing 2.4.6
pytest 5.4.1
pytest-forked 1.1.3
pytest-xdist 1.31.0
setuptools 46.0.0
six 1.14.0
wcwidth 0.1.8
zipp 3.1.0
pytest 5.4.1
Ubuntu 19.10
Content of test_junit.py:
def test_stdout():
print('Testing...')
Let's run the test: pytest test_junit.py -v --junitxml result.xml
Content of result.xml:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite errors="0" failures="0" hostname="likai-ubuntu" name="pytest" skipped="0" tests="1" time="0.010" timestamp="2020-03-20T19:11:11.630551">
<testcase classname="capture.test_junit" file="capture/test_junit.py" line="0" name="test_capture" time="0.000" />
</testsuite>
</testsuites>
If I run the same test with pytest 5.3.5, the result contains stdout:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite errors="0" failures="0" hostname="likai-ubuntu" name="pytest" skipped="0" tests="1" time="0.011" timestamp="2020-03-20T19:17:00.902714">
<testcase classname="capture.test_junit" file="capture/test_junit.py" line="0" name="test_capture" time="0.000">
<system-out>Testing...</system-out>
</testcase>
</testsuite>
</testsuites>
Well, here is the change: #6469
By default, no captured output is written.
https://docs.pytest.org/en/latest/reference.html#confval-junit_logging
How can we turn on --junit_logging=all by command line?
How can we turn on --junit_logging=all by command line?
this worked.
-o junit_logging=all
Are you getting system-out now?
yes thank you
Most helpful comment
-o junit_logging=all