Skip to content

subtests not itemized in Junit XML #13876

@codambro

Description

@codambro

Testing with tip-of-main to try out new subtests integration. Simple subtest example

def test_subtests(subtests):
    """Simple subtest example"""
    for i in range(2):
        with subtests.test(msg="is_even", i=i):
            assert i % 2 == 0, f"{i} is odd"

I expect each subtest to appear as a in a generated JUnit XML. Instead, only the top level is:

<testcase classname="samples.test_sample" name="test_subtests" time="0.006">
<failure message="AssertionError: 1 is odd&#10;assert (1 % 2) == 0">subtests = &lt;_pytest.subtests.Subtests object at 0x103b1d580&gt;

    def test_subtests(subtests):
        """Simple subtest example"""
        for i in range(2):
            with subtests.test(msg="is_even", i=i):
&gt;               assert i % 2 == 0, f"{i} is odd"
E               AssertionError: 1 is odd
E               assert (1 % 2) == 0

samples/test_sample.py:87: AssertionError</failure><system-out>--------------------------------- Captured Log ---------------------------------

</system-out>
<failure message="contains 1 failed subtest">contains 1 failed subtest</failure>
<system-out>--------------------------------- Captured Log ---------------------------------

</system-out>
</testcase>
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: junitxmlrelated to the junitxml builtin pluginplugin: subtestsrelated to the subtests builtin plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions