Skip to content
Merged
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
4 changes: 3 additions & 1 deletion docs/internals/extensions/source_code_linker.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_feature():
1. **XML Parsing** (`xml_parser.py`)
- Scans `bazel-testlogs/` for `test.xml` files.
- Parses test cases and extracts:
- Name
- Name & Classname
- File path
- Line
- Result (e.g. passed, failed, skipped)
Expand All @@ -104,6 +104,8 @@ def test_feature():
- `DataFromTestCase` (used for external needs)
- `DataForTestLink` (used for linking tests to requirements)

> If there is a Classname then it gets combined with the function name for the displayed link as follows: `Classname__Functionname`

2. **Need Linking**
- Generates external Sphinx needs from `DataFromTestCase`.
- Creates `testlink` attributes on linked requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"TestLinks": [
{
"name": "test_system_startup_time",
"name": "TestRequirementsCoverage__test_system_startup_time",
"file": "src/tests/testfile_2.py",
"line": 25,
"need": "TREQ_ID_1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"result_text": ""
},
{
"name": "test_system_startup_time",
"name": "TestRequirementsCoverage__test_system_startup_time",
"file": "src/tests/testfile_2.py",
"line": 25,
"need": "TREQ_ID_1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@

@pytest.fixture()
def example_source_link_text_all_ok(sphinx_base_dir: Path):
return {

Check warning on line 307 in src/extensions/score_source_code_linker/tests/test_source_code_link_integration.py

View workflow job for this annotation

GitHub Actions / lint

Return type, "dict[str, Unknown]", is partially unknown (reportUnknownVariableType)
"TREQ_ID_1": [
NeedLink(
file=Path("src/implementation2.py"),
Expand Down Expand Up @@ -339,7 +339,7 @@
return {
"TREQ_ID_1": [
DataForTestLink(
name="test_system_startup_time",
name="TestRequirementsCoverage__test_system_startup_time",
file=Path("src/tests/testfile_2.py"),
need="TREQ_ID_1",
line=25,
Expand Down
14 changes: 10 additions & 4 deletions src/extensions/score_source_code_linker/xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,17 @@ def read_test_xml_file(file: Path) -> tuple[list[DataOfTestCase], list[str]]:
for testsuite in root.findall("testsuite"):
for testcase in testsuite.findall("testcase"):
case_properties = {}
testname = testcase.get("name")
assert testname is not None, (
f"Testcase: {testcase} does not have a 'name' attribute. "
"This is mandatory. This should not happen, something is wrong."
testcasename = testcase.get("name", "")
testclassname = testcase.get("classname", "")
assert testclassname or testcasename, (
f"Testcase: {testcase} does not have a 'name' or 'classname' attribute."
"One of which is mandatory. This should not happen, something is wrong."
)
if testclassname:
testcn = testclassname.split(".")[-1]
testname = "__".join([testcn, testcasename])
else:
testname = testcasename
test_file = testcase.get("file")
line = testcase.get("line")

Expand Down
Loading