Skip to content

[junitxml] Add support for record_property fixture for xunit2 junit_family #14315

@harmin-parra

Description

@harmin-parra

What's the problem this feature will solve?

When using junit_family=xunit2, I cannot use the record_property fixture to add properties at the testcase level.

I want to generate a JUnit report like this:

<?xml version="1.0" encoding="utf-8"?>
<testsuites name="pytest tests">
  <testsuite name="pytest" errors="0" failures="0" skipped="0" tests="3" time="22.010" timestamp="2026-03-21T11:57:36.596215+00:00" hostname="fac927d2637c">
    <testcase classname="tests.ajax_test" name="test_ajax_verification_with_intercept[firefox]" file="tests/ajax_test.py" line="6" time="8.571"/>
    <testcase classname="tests.ajax_test" name="test_ajax_verification_with_expect[firefox]" file="tests/ajax_test.py" line="56" time="7.441"/>
    <testcase classname="tests.webform_test" name="test_web_form[firefox]" file="tests/webform_test.py" line="8" time="5.973">
      <properties>
        <property name="issues" value="JIRA-123, JIRA-987"/>
        <property name="testrail_attachment" value="screenshots/image.png"/>
        <property name="video" value="videos/f353ea5f-3a1a-4343-9251-166c511de8b1.webm"/>
      </properties>
    </testcase>
  </testsuite>
</testsuites>

Describe the solution you'd like

I want to be able to use the record_property fixture in the same way as with the xunit1 junit_family

def test_sample(record_property):
    record_property("testrail_attachment", "screenshots/image.png")

Alternative Solutions

Use xunit1 instead of xunit2

Additional context

Several tools support/mention the property attribute for testcase
Examples:
https://github.com/testmoapp/junitxml
https://www.checkov.io/8.Outputs/JUnit%20XML.html
https://docs.getxray.app/space/XRAY/301506710/Taking+advantage+of+JUnit+XML+reports

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions