Test Overview
This test simulates a software delivery pipeline with multiple stages and test gates. It verifies that the pipeline stops if a test gate fails, ensuring only quality code moves forward.
This test simulates a software delivery pipeline with multiple stages and test gates. It verifies that the pipeline stops if a test gate fails, ensuring only quality code moves forward.
class Pipeline: def __init__(self): self.stages = [] def add_stage(self, name, test_gate): self.stages.append({'name': name, 'test_gate': test_gate}) def run(self): for stage in self.stages: print(f"Running stage: {stage['name']}") if not stage['test_gate'](): print(f"Test gate failed at stage: {stage['name']}") return False return True # Define test gates def unit_tests(): # Simulate unit tests passing return True def integration_tests(): # Simulate integration tests passing return True def e2e_tests(): # Simulate end-to-end tests failing return False # Setup pipeline pipeline = Pipeline() pipeline.add_stage('Build', unit_tests) pipeline.add_stage('Integration', integration_tests) pipeline.add_stage('E2E', e2e_tests) # Run pipeline result = pipeline.run() assert result == False, "Pipeline should fail due to E2E test gate failure"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Initialize pipeline and add stages with test gates | Pipeline has 3 stages: Build, Integration, E2E with respective test gates | - | PASS |
| 2 | Run pipeline: execute 'Build' stage test gate (unit_tests) | Unit tests simulated as passing | unit_tests() returns True | PASS |
| 3 | Run pipeline: execute 'Integration' stage test gate (integration_tests) | Integration tests simulated as passing | integration_tests() returns True | PASS |
| 4 | Run pipeline: execute 'E2E' stage test gate (e2e_tests) | E2E tests simulated as failing | e2e_tests() returns False | PASS |
| 5 | Pipeline stops due to failed E2E test gate | Pipeline run returns False indicating failure | assert result == False | PASS |