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 |
test gates in a software delivery pipeline?stages:
- build
- test
- deploy
test_gate:
stage: test
condition: tests_passed == true
action: continue_pipeline
If tests_passed is false, what happens next?tests_passed == true. If false, the condition fails.stages: - build - test - deploy test_gate: stage: test condition: tests_passed action: continue_pipeline But the pipeline always proceeds even when tests fail. What is the likely error?
tests_passed alone, which may not evaluate correctly if it's not a boolean.tests_passed == true ensures the gate only passes when tests truly pass.1. Build 2. Unit Test 3. Integration Test 4. Deploy Test gates are set after Unit Test and Integration Test stages. If the Integration Test gate fails, what should happen to ensure safe deployment?
Pass the test and this pattern moves unknown