Test Overview
This test simulates prioritizing test cases based on risk and impact to ensure critical features are tested first. It verifies that high-priority tests run before lower-priority ones.
This test simulates prioritizing test cases based on risk and impact to ensure critical features are tested first. It verifies that high-priority tests run before lower-priority ones.
import unittest class TestPrioritization(unittest.TestCase): def setUp(self): # Simulate test cases with priorities self.test_cases = [ {'name': 'Login Test', 'priority': 1}, # High priority {'name': 'Profile Update Test', 'priority': 3}, # Low priority {'name': 'Payment Processing Test', 'priority': 2} # Medium priority ] def test_run_order(self): # Sort test cases by priority (1 is highest) sorted_tests = sorted(self.test_cases, key=lambda x: x['priority']) # Check that the first test is the highest priority self.assertEqual(sorted_tests[0]['name'], 'Login Test') # Check that the last test is the lowest priority self.assertEqual(sorted_tests[-1]['name'], 'Profile Update Test') if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test suite starts | TestPrioritization class loaded with test cases and priorities | - | PASS |
| 2 | setUp method runs to prepare test cases with priorities | List of test cases with names and priority numbers ready | - | PASS |
| 3 | test_run_order method sorts test cases by priority | Test cases sorted: Login Test (1), Payment Processing Test (2), Profile Update Test (3) | Check first test case name is 'Login Test' | PASS |
| 4 | test_run_order method checks last test case name | Last test case is 'Profile Update Test' | Check last test case name is 'Profile Update Test' | PASS |
| 5 | Test suite finishes with all assertions passed | All test cases verified in correct priority order | - | PASS |