Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/conf.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we move the config into ubproject.toml?

Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@
# Default is "file" but sphinx-codelinks also uses "file" for source code paths
tr_file_option = "test_file"

# Make the "verifies" JUnit XML property available as a sphinx-needs field on
# every imported test-run need so that requirement traceability is captured
# directly from the test output.
# Docs: https://sphinx-test-reports.readthedocs.io/en/latest/configuration.html#tr-extra-options
tr_extra_options = ["verifies"]

# Map the "verifies" property to the sphinx-needs "links" link type so that
# test-run needs automatically link back to the requirements they verify.
# Docs: https://sphinx-test-reports.readthedocs.io/en/latest/configuration.html#tr-property-link-types
tr_property_link_types = {
"verifies": "links",
}

###############################################################################
# SPHINX-TEST-REPORTS Config END
###############################################################################
Expand Down
36 changes: 30 additions & 6 deletions docs/testsuites/coffee_machine_junit.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
<?xml version='1.0' encoding='utf-8'?>
<testsuites>
<testsuite name="coffee_machine" tests="6" failures="0" errors="0">
<testcase classname="interfaces::tests::test_brew_ctrl_status_fault_detection" name="TEST_SAFETY_SHUTDOWN" time="0.001" />
<testcase classname="interfaces::tests::test_brew_strength_enum" name="TEST_BREW_STRENGTH" time="0.001" />
<testcase classname="interfaces::tests::test_sensor_data_creation" name="TEST_TEMP_CONTROL" time="0.001" />
<testcase classname="interfaces::tests::test_temp_ctrl_status_fault_detection" name="TEST_SAFETY_SHUTDOWN" time="0.001" />
<testcase classname="interfaces::tests::test_temperature_status_conversions" name="TEST_TEMP_CONTROL" time="0.001" />
<testcase classname="interfaces::tests::test_user_command_variants" name="TEST_BUTTON_DEBOUNCE" time="0.001" />
<testcase classname="interfaces::tests::test_brew_ctrl_status_fault_detection" name="TEST_SAFETY_SHUTDOWN" time="0.001">
<properties>
<property name="verifies" value="SWREQ_OVERTEMP_SHUTDOWN SWREQ_WATER_LEVEL" />
</properties>
</testcase>
<testcase classname="interfaces::tests::test_brew_strength_enum" name="TEST_BREW_STRENGTH" time="0.001">
<properties>
<property name="verifies" value="SWREQ_BREW_STRENGTH" />
</properties>
</testcase>
<testcase classname="interfaces::tests::test_sensor_data_creation" name="TEST_TEMP_CONTROL" time="0.001">
<properties>
<property name="verifies" value="SWREQ_TEMP_REGULATION" />
</properties>
</testcase>
<testcase classname="interfaces::tests::test_temp_ctrl_status_fault_detection" name="TEST_SAFETY_SHUTDOWN" time="0.001">
<properties>
<property name="verifies" value="SWREQ_OVERTEMP_SHUTDOWN SWREQ_WATER_LEVEL" />
</properties>
</testcase>
<testcase classname="interfaces::tests::test_temperature_status_conversions" name="TEST_TEMP_CONTROL" time="0.001">
<properties>
<property name="verifies" value="SWREQ_TEMP_REGULATION" />
</properties>
</testcase>
<testcase classname="interfaces::tests::test_user_command_variants" name="TEST_BUTTON_DEBOUNCE" time="0.001">
<properties>
<property name="verifies" value="SWREQ_BUTTON_INPUT" />
</properties>
</testcase>
</testsuite>
</testsuites>
15 changes: 15 additions & 0 deletions scripts/cargo_test_to_junit.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I was thinking we could demonstrate how to provide test run information from cargo, like: logs, execution time, ...

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
"interfaces::tests::test_user_command_variants": "TEST_BUTTON_DEBOUNCE",
}

# Map each test spec ID to the space-separated list of SW requirement IDs it
# verifies. These are emitted as a ``<properties><property name="verifies"
# …/></properties>`` block so that sphinx-test-reports can map them to
# sphinx-needs link fields via ``tr_property_link_types``.
SPEC_TO_SWREQ: dict[str, str] = {
"TEST_TEMP_CONTROL": "SWREQ_TEMP_REGULATION",
"TEST_BREW_STRENGTH": "SWREQ_BREW_STRENGTH",
"TEST_BUTTON_DEBOUNCE": "SWREQ_BUTTON_INPUT",
"TEST_SAFETY_SHUTDOWN": "SWREQ_OVERTEMP_SHUTDOWN SWREQ_WATER_LEVEL",
}


def main() -> None:
text = sys.stdin.read()
Expand Down Expand Up @@ -60,6 +71,10 @@ def main() -> None:
)
if status == "FAILED":
ET.SubElement(tc, "failure", message="Test failed")
swreqs = SPEC_TO_SWREQ.get(spec_id)
if swreqs:
props = ET.SubElement(tc, "properties")
ET.SubElement(props, "property", name="verifies", value=swreqs)

tree = ET.ElementTree(root)
ET.indent(tree, space=" ")
Expand Down
Loading