Skip to content

Showcase: Use sphinx-test-reports JUnit XML properties for requirement traceability #62

@arnoox

Description

@arnoox

Summary

Demonstrate the new sphinx-test-reports feature that maps JUnit XML <properties> to sphinx-needs fields, enabling automatic requirement traceability from test results.

Background

sphinx-test-reports now supports extracting <properties> elements from JUnit XML and mapping them to sphinx-needs fields. This allows test frameworks (pytest, JUnit 5, Maven Surefire, etc.) to embed requirement IDs directly in test output, which then appear as traceable links in the documentation.

What to implement

  1. Add <properties> to the coffee-machine JUnit XML (docs/testsuites/coffee_machine_junit.xml):
<testcase classname="interfaces::tests::test_brew_ctrl_status_fault_detection" name="TEST_SAFETY_SHUTDOWN" time="0.001">
  <properties>
    <property name="verifies" value="SWREQ_SAFE_SHUTDOWN"/>
  </properties>
</testcase>
  1. Configure conf.py with the new options:
# Make these JUnit properties available as sphinx-needs fields
tr_extra_options = ["verifies"]

# Map the "verifies" property to sphinx-needs links
tr_property_link_types = {
    "verifies": "links",
}
  1. Verify that the rendered test-run needs automatically link back to the requirements they verify, creating a full traceability chain from requirement → test case → test result.

Acceptance Criteria

  • coffee_machine_junit.xml contains <properties> with verifies entries pointing to existing requirement IDs
  • conf.py has tr_extra_options and tr_property_link_types configured
  • make html builds without errors
  • Rendered test-run needs show links back to the requirements they verify

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions