Test Overview
This test simulates reporting a defect in a software application. It verifies that the defect report contains all necessary information such as steps to reproduce, expected and actual results, severity, and environment details.
This test simulates reporting a defect in a software application. It verifies that the defect report contains all necessary information such as steps to reproduce, expected and actual results, severity, and environment details.
import unittest class DefectReport: def __init__(self, title, steps, expected, actual, severity, environment): self.title = title self.steps = steps self.expected = expected self.actual = actual self.severity = severity self.environment = environment def is_complete(self): return all([ bool(self.title.strip()), bool(self.steps.strip()), bool(self.expected.strip()), bool(self.actual.strip()), self.severity in ['Low', 'Medium', 'High', 'Critical'], bool(self.environment.strip()) ]) class TestDefectReporting(unittest.TestCase): def test_defect_report_completeness(self): report = DefectReport( title="Login button not working", steps="1. Open login page\n2. Enter valid credentials\n3. Click login button", expected="User should be logged in and redirected to dashboard", actual="Nothing happens when login button is clicked", severity="High", environment="Windows 11, Chrome 114" ) self.assertTrue(report.is_complete(), "Defect report is incomplete or invalid") if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test framework initialized, ready to run test_defect_report_completeness | - | PASS |
| 2 | Create DefectReport object with all required fields filled | DefectReport instance created with title, steps, expected, actual, severity, environment | - | PASS |
| 3 | Call is_complete() method to verify all fields are valid and present | Method checks each field for non-empty and severity is valid | All fields are non-empty and severity is one of ['Low', 'Medium', 'High', 'Critical'] | PASS |
| 4 | Assert that is_complete() returns True | Assertion verifies defect report completeness | assertTrue(report.is_complete()) | PASS |
| 5 | Test ends successfully | Test framework reports test_defect_report_completeness PASSED | - | PASS |