What is the main purpose of a traceability matrix in software testing?
Think about how testers ensure every requirement is covered by tests.
A traceability matrix links requirements to their corresponding test cases. This ensures that all requirements have been tested and nothing is missed.
Given the following traceability matrix represented as a dictionary where keys are requirement IDs and values are lists of test case IDs, how many requirements have no test cases linked?
traceability_matrix = {
'REQ-1': ['TC-1', 'TC-2'],
'REQ-2': [],
'REQ-3': ['TC-3'],
'REQ-4': []
}
count = sum(1 for tests in traceability_matrix.values() if len(tests) == 0)
print(count)Count how many requirements have empty test case lists.
REQ-2 and REQ-4 have empty lists, so 2 requirements have no test cases linked.
Which assertion correctly verifies that every requirement in the traceability matrix has at least one test case linked?
traceability_matrix = {
'REQ-1': ['TC-1'],
'REQ-2': ['TC-2', 'TC-3'],
'REQ-3': ['TC-4']
}Think about how to check that no requirement has zero test cases.
Using all(len(tests) > 0) ensures every requirement has at least one linked test case.
Identify the error in the following code snippet that aims to print requirements without test cases:
traceability_matrix = {
'REQ-1': ['TC-1'],
'REQ-2': [],
'REQ-3': ['TC-2']
}
for req, tests in traceability_matrix.items():
if tests == None:
print(req)Think about what value an empty list has compared to None.
The code checks if tests == None, but empty lists are not None. It should check if tests is empty using if not tests: or if len(tests) == 0:.
In a test automation framework, which approach best integrates a traceability matrix to ensure all requirements are tested automatically?
Consider how automation can help track coverage and generate reports.
Using a mapping file to link requirements and test cases allows automated coverage reports, ensuring traceability and completeness.