Which of the following best describes the purpose of the build stage in a software pipeline?
Think about what happens before testing and deployment.
The build stage compiles the source code and produces executable files or packages. This is necessary before running tests or deploying.
In a pipeline, a test gate is configured to fail the pipeline if any unit test fails. Given the following test results, what will be the pipeline outcome?
Unit tests passed: 95/100
Integration tests passed: 50/50
Test gates often require 100% pass rate for critical tests.
The test gate is set to fail if any unit test fails. Since 5 unit tests failed, the pipeline fails regardless of integration test results.
Consider this simplified pipeline stage execution code snippet:
stages = ['build', 'test', 'deploy']
results = []
for stage in stages:
if stage == 'test':
results.append('test skipped')
break
results.append(stage + ' completed')
print(results)What is the output after running this code?
Note the break statement inside the loop.
The loop appends 'build completed', then encounters 'test', appends 'test skipped', and breaks the loop, so 'deploy' is not processed.
A pipeline test gate is supposed to block deployment if code coverage is below 80%. The following code snippet is used to check coverage:
coverage = 78
if coverage < 80:
print('Pass test gate')
else:
print('Fail test gate')Why does the pipeline allow deployment even when coverage is 78%?
Check the logic of the if-else condition carefully.
The if condition is reversed: coverage=78 <80 is true, so it prints 'Pass test gate', allowing deployment. It should print 'Fail test gate' when coverage is below 80%.
You want to design a test gate that blocks deployment if any of these conditions fail:
- All unit tests pass
- Code coverage is at least 85%
- No critical bugs are open
Which of the following pseudocode snippets correctly implements this test gate?
unit_tests_passed = True
coverage = 87
critical_bugs_open = 0
if ???:
print('Pass test gate')
else:
print('Fail test gate')All conditions must be true to pass the gate.
Using 'and' ensures all conditions must be met. 'Or' would allow passing if any single condition is true, which is incorrect.