Test Overview
This test simulates a simple software development process where testing starts early (shift-left). It verifies that bugs are caught early during development rather than later in production.
This test simulates a simple software development process where testing starts early (shift-left). It verifies that bugs are caught early during development rather than later in production.
class SoftwareDevelopmentProcess: def __init__(self): self.code_written = False self.tests_run = False self.bugs_found = 0 def write_code(self): self.code_written = True def run_tests_early(self): if not self.code_written: raise Exception("Cannot test before code is written") self.tests_run = True # Simulate finding bugs early self.bugs_found = 2 def deploy(self): if not self.tests_run: # Bugs found late self.bugs_found = 5 import unittest class TestShiftLeft(unittest.TestCase): def test_shift_left(self): process = SoftwareDevelopmentProcess() process.write_code() process.run_tests_early() process.deploy() # Assert bugs found early are fewer than if tested late self.assertLess(process.bugs_found, 5) if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Create SoftwareDevelopmentProcess instance | New process object with no code written, no tests run, zero bugs found | - | PASS |
| 2 | Call write_code() to simulate writing code | Code written flag set to True | - | PASS |
| 3 | Call run_tests_early() to simulate early testing | Tests run flag set to True, bugs_found set to 2 | Verify tests_run is True and bugs_found is 2 | PASS |
| 4 | Call deploy() to simulate deployment | Since tests_run is True, bugs_found remains 2 | Verify bugs_found is less than 5 | PASS |
| 5 | Assert bugs_found < 5 to confirm early testing effectiveness | bugs_found is 2 | assertLess(2, 5) passes | PASS |