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 |
test prioritization in software testing?Test A: failed 2 days ago Test B: passed last run Test C: failed 10 days ago Test D: never failed
1. Test X (no recent changes, no failures) 2. Test Y (recent changes, no failures) 3. Test Z (no recent changes, failed last run) 4. Test W (recent changes, failed last run)
Test 1: covers critical feature, no recent changes, failed last run Test 2: covers minor feature, recent changes, passed last run Test 3: covers critical feature, recent changes, passed last run Test 4: covers minor feature, no recent changes, never failed Test 5: covers critical feature, recent changes, failed last run
Pass the test and this pattern moves unknown