Coverage Serialization#
Save and load coverage data for decoupled matrix generation.
The coverage module provides functions to persist test coverage data to disk
(as .jamb files) and reload it later. This enables workflows where tests
are run once and matrices are regenerated multiple times without re-running
tests.
Constants#
- jamb.coverage.COVERAGE_FILE#
Default filename for coverage data:
.jamb
Functions#
- jamb.coverage.save_coverage(coverage, graph, output_path='.jamb', metadata=None, manual_tc_ids=None)[source]#
Save coverage data to .jamb file for later matrix generation.
- Parameters:
coverage (
dict[str,ItemCoverage]) – Coverage data mapping UIDs to ItemCoverage.graph (
TraceabilityGraph) – The traceability graph with all items and relationships.output_path (
str) – Path to write the coverage file (default: .jamb).metadata (
MatrixMetadata|None) – Optional matrix metadata for IEC 62304 compliance.manual_tc_ids (
dict[str,str] |None) – Optional dict mapping nodeid to manual TC ID.
- Return type:
- jamb.coverage.load_coverage(input_path='.jamb')[source]#
Load coverage data from .jamb file.
- Parameters:
input_path (
str) – Path to the coverage file (default: .jamb).- Returns:
tuple[dict[str,ItemCoverage],TraceabilityGraph,MatrixMetadata|None,dict[str,str]] – Tuple of (coverage dict, TraceabilityGraph, optional MatrixMetadata, manual_tc_ids). manual_tc_ids maps test nodeid to manual TC ID (empty dict if none).- Raises:
FileNotFoundError – If the coverage file does not exist.
ValueError – If the coverage file is invalid or unsupported version.
- Return type:
tuple[dict[str, ItemCoverage], TraceabilityGraph, MatrixMetadata | None, dict[str, str]]
File Format#
The .jamb file is a JSON document containing:
version: File format version (for forward compatibility)
coverage: Dict mapping item UIDs to coverage data (item details and linked tests)
graph: Full traceability graph with all items and relationships
metadata: Optional IEC 62304 metadata (tester ID, timestamps, environment)
manual_tc_ids: Optional dict mapping test nodeids to manual TC IDs
This file is automatically created by pytest --jamb and consumed by
jamb matrix to regenerate matrices without re-running tests.