1.4 KiB
1.4 KiB
Requirement Traceability
This document shows how requirements map to tests via pytest markers and docstrings, plus how to visualize coverage.
Conventions
- Requirement IDs:
REQ-xxx - Use markers in tests:
@pytest.mark.req_001,@pytest.mark.req_002, etc. - Include readable requirement list in the test docstring under
Requirements:
Example
@pytest.mark.req_001
@pytest.mark.req_003
"""
Title: Mock LIN Interface - Send/Receive Echo Test
Requirements: REQ-001, REQ-003
"""
Mermaid: Requirement → Tests map
Note: This is illustrative; maintain it as your suite grows.
flowchart LR
R1[REQ-001: LIN Basic Ops]
R2[REQ-002: Master Request/Response]
R3[REQ-003: Frame Validation]
R4[REQ-004: Timeout Handling]
T1[test_mock_send_receive_echo]
T2[test_mock_request_synthesized_response]
T3[test_mock_receive_timeout_behavior]
T4[test_mock_frame_validation_boundaries]
R1 --> T1
R3 --> T1
R2 --> T2
R4 --> T3
R1 --> T4
R3 --> T4
Generating a live coverage artifact (optional)
You can extend conftest_plugin.py to emit a JSON file with requirement-to-test mapping at the end of a run by scanning markers and docstrings. This can fuel dashboards or CI gates.
Suggested JSON shape:
{
"requirements": {
"REQ-001": ["tests/test_smoke_mock.py::TestMockLinInterface::test_mock_send_receive_echo", "..."]
},
"uncovered": ["REQ-010", "REQ-012"]
}