Description
Let's consider testcase that fails in the call thus resulting in 1 failure
and then when it's teardown fixture is executed it fails there as well
thus resulting in 1 error. So we have 1 failure and 1 error for the
same test. This results in the junitxml XML report, as two different
attributes, one error and one failure for the same testcase.
However, until pytest 2.8.4, in such tests the XML file had two
testcase elements, one containing the failure in the call of the test,
and a second testcase element containing the error in the teardown.
From pytest 2.8.5 and after the XML file has only one testcase element
for such test, and this contains both fail and error sections.
The problem with the new XML files is that they cannot
be correctly parsed by Jenkins Junit plugin. The reason behind that is
that they violate the JUnit XML format, which is built so that in
every testcase element you can have as a child only one of {skipped,
error, failure, system-out, system-err} elements.
I would like your opinion on that, and if you agree on reverting the old style
XML reports I would be happy to send a PR.
@RonnyPfannschmidt
EXAMPLE:
The following code will have difference in the XML report between
pytest versions.
@pytest.fixture()
def setup_class(request):
def finalize():
raise Exception("test teardown Exception!")
request.addfinalizer(finalize)
def test_1(setup_class):
raise Exception("test main Exception!")
pytest version >= 2.4.5
<testsuite errors="1" failures="1" name="pytest" skips="0" tests="1"
time="0.009">
<testcase classname="test" file="test.py" line="9" name="test_1"
time="0.000397205352783">
<failure message="Exception: test main Exception!">
.. some info...
</failure>
<error message="test setup failure">
..some info about teardown exception...
</error>
</testcase>
</testsuite>
pytest version < 2.4.5
<testsuite errors="1" failures="1" name="pytest" skips="0" tests="1"
time="0.009">
<testcase classname="test" file="test.py" line="9" name="test_1"
time="0.000282049179077">
<failure message="Exception: test main Exception!">
.. some info...
</failure>
</testcase>
<testcase classname="test" file="test.py" line="9" name="test_1"
time="0.00037407875061">
<error message="test setup failure">
.. some info...
</error>
</testcase>
</testsuite>