Test Overview
This test simulates the defect lifecycle process in a software project. It verifies that a defect moves through all expected states from New to Closed, ensuring proper tracking and resolution.
This test simulates the defect lifecycle process in a software project. It verifies that a defect moves through all expected states from New to Closed, ensuring proper tracking and resolution.
class Defect: def __init__(self): self.state = 'New' def assign(self): if self.state == 'New': self.state = 'Assigned' def start_progress(self): if self.state == 'Assigned': self.state = 'In Progress' def fix(self): if self.state == 'In Progress': self.state = 'Fixed' def verify(self): if self.state == 'Fixed': self.state = 'Verified' def close(self): if self.state == 'Verified': self.state = 'Closed' def test_defect_lifecycle(): defect = Defect() assert defect.state == 'New' defect.assign() assert defect.state == 'Assigned' defect.start_progress() assert defect.state == 'In Progress' defect.fix() assert defect.state == 'Fixed' defect.verify() assert defect.state == 'Verified' defect.close() assert defect.state == 'Closed' print('Defect lifecycle test passed') if __name__ == '__main__': test_defect_lifecycle()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts and creates a new defect instance | Defect state is 'New' | Assert defect.state == 'New' | PASS |
| 2 | Assign the defect | Defect state changes to 'Assigned' | Assert defect.state == 'Assigned' | PASS |
| 3 | Start progress on the defect | Defect state changes to 'In Progress' | Assert defect.state == 'In Progress' | PASS |
| 4 | Fix the defect | Defect state changes to 'Fixed' | Assert defect.state == 'Fixed' | PASS |
| 5 | Verify the defect fix | Defect state changes to 'Verified' | Assert defect.state == 'Verified' | PASS |
| 6 | Close the defect | Defect state changes to 'Closed' | Assert defect.state == 'Closed' | PASS |
| 7 | Test ends successfully | Defect lifecycle completed | - | PASS |