0
0
Testing Fundamentalstesting~10 mins

Traceability matrix in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test verifies that all requirements have corresponding test cases by checking the traceability matrix completeness.

Test Code - unittest
Testing Fundamentals
import unittest

class TraceabilityMatrixTest(unittest.TestCase):
    def setUp(self):
        # Sample requirements and test cases mapping
        self.requirements = ['REQ-1', 'REQ-2', 'REQ-3']
        self.test_cases = {
            'REQ-1': ['TC-1', 'TC-2'],
            'REQ-2': ['TC-3'],
            'REQ-3': ['TC-4']
        }

    def test_all_requirements_have_tests(self):
        for req in self.requirements:
            with self.subTest(requirement=req):
                self.assertIn(req, self.test_cases, f"Requirement {req} missing in test cases")
                self.assertTrue(len(self.test_cases[req]) > 0, f"No test cases linked to {req}")

if __name__ == '__main__':
    unittest.main()
Execution Trace - 6 Steps
StepActionSystem StateAssertionResult
1Test startsTest runner initialized with TraceabilityMatrixTest-PASS
2setUp method runs to prepare requirements and test cases dataRequirements list and test cases dictionary loaded-PASS
3Test method test_all_requirements_have_tests begins checking REQ-1Checking if REQ-1 is in test_cases and has linked test casesassertIn('REQ-1', test_cases) and len(test_cases['REQ-1']) > 0PASS
4Test method checks REQ-2Checking if REQ-2 is in test_cases and has linked test casesassertIn('REQ-2', test_cases) and len(test_cases['REQ-2']) > 0PASS
5Test method checks REQ-3Checking if REQ-3 is in test_cases and has linked test casesassertIn('REQ-3', test_cases) and len(test_cases['REQ-3']) > 0PASS
6All requirements verified with linked test casesTest completes successfully-PASS
Failure Scenario
Failing Condition: A requirement is missing from the test cases dictionary or has no linked test cases
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about each requirement?
ARequirements are sorted alphabetically
BEach test case has multiple requirements
CEach requirement has at least one linked test case
DTest cases are executed in order
Key Result
Using a traceability matrix test ensures every requirement is covered by at least one test case, preventing gaps in testing coverage.