Bird
Raised Fist0
Testing Fundamentalstesting~20 mins

Pipeline stages and test gates in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Pipeline Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Pipeline Stages

Which of the following best describes the purpose of the build stage in a software pipeline?

AIt monitors application performance after deployment.
BIt deploys the application to the production environment.
CIt runs automated tests to verify code correctness.
DIt compiles the source code and creates executable artifacts.
Attempts:
2 left
💡 Hint

Think about what happens before testing and deployment.

❓ assertion
intermediate
2:00remaining
Test Gate Logic in Pipeline

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
APipeline passes because most unit tests passed.
BPipeline passes because integration tests passed.
CPipeline fails because some unit tests failed.
DPipeline fails because integration tests are mandatory.
Attempts:
2 left
💡 Hint

Test gates often require 100% pass rate for critical tests.

❓ Predict Output
advanced
2:00remaining
Pipeline Stage Execution Order

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?

A['build completed', 'test skipped']
B['build completed']
C['build completed', 'test completed', 'deploy completed']
D['test skipped']
Attempts:
2 left
💡 Hint

Note the break statement inside the loop.

🔧 Debug
advanced
2:00remaining
Debugging a Test Gate Failure

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%?

ABecause 78 is less than 80, so it should fail but the code logic is reversed.
BBecause the condition uses '>' instead of '>=' causing 80% to fail but 78% to pass.
CBecause the condition only passes if coverage is strictly greater than 80, so 78 fails and blocks deployment.
DBecause the code prints 'Fail test gate' when coverage is below 80%, so deployment is blocked.
Attempts:
2 left
💡 Hint

Check the logic of the if-else condition carefully.

❓ framework
expert
3:00remaining
Designing a Test Gate for Multiple Criteria

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')
Aif unit_tests_passed or coverage >= 85 or critical_bugs_open == 0:
Bif unit_tests_passed and coverage >= 85 and critical_bugs_open == 0:
Cif not unit_tests_passed and coverage < 85 and critical_bugs_open > 0:
Dif unit_tests_passed and coverage > 85 and critical_bugs_open != 0:
Attempts:
2 left
💡 Hint

All conditions must be true to pass the gate.

Practice

(1/5)
1. What is the main purpose of test gates in a software delivery pipeline?
easy
A. To write new test cases for the software
B. To check if tests pass before moving to the next stage
C. To deploy the software to production automatically
D. To monitor user feedback after release

Solution

  1. Step 1: Understand the role of test gates

    Test gates act as checkpoints that verify if tests have passed successfully before allowing the pipeline to continue.
  2. Step 2: Differentiate from other pipeline actions

    Deploying software or writing tests are separate activities, not the main function of test gates.
  3. Final Answer:

    To check if tests pass before moving to the next stage -> Option B
  4. Quick Check:

    Test gates = verify tests pass [OK]
Hint: Test gates stop pipeline if tests fail [OK]
Common Mistakes:
  • Confusing test gates with deployment steps
  • Thinking test gates create tests
  • Assuming test gates handle user feedback
2. Which of the following is the correct order of pipeline stages in a typical CI/CD pipeline?
easy
A. Test -> Build -> Deploy -> Release
B. Release -> Build -> Test -> Deploy
C. Deploy -> Build -> Test -> Release
D. Build -> Test -> Deploy -> Release

Solution

  1. Step 1: Recall standard pipeline flow

    The usual order is to first build the software, then run tests, deploy to an environment, and finally release to users.
  2. Step 2: Match options to this order

    Build -> Test -> Deploy -> Release matches this sequence exactly.
  3. Final Answer:

    Build -> Test -> Deploy -> Release -> Option D
  4. Quick Check:

    Build before Test before Deploy [OK]
Hint: Build comes before testing in pipelines [OK]
Common Mistakes:
  • Swapping build and test stages
  • Deploying before testing
  • Releasing before deployment
3. Consider this simplified pipeline code snippet:
stages:
  - build
  - test
  - deploy

test_gate:
  stage: test
  condition: tests_passed == true
  action: continue_pipeline

If tests_passed is false, what happens next?
medium
A. Pipeline stops and does not proceed to deploy
B. Pipeline skips test stage and goes to deploy
C. Pipeline continues to deploy regardless
D. Pipeline restarts from build stage

Solution

  1. Step 1: Analyze the test gate condition

    The test gate checks if tests_passed == true. If false, the condition fails.
  2. Step 2: Understand pipeline behavior on failed test gate

    When the condition fails, the pipeline stops and does not continue to the deploy stage.
  3. Final Answer:

    Pipeline stops and does not proceed to deploy -> Option A
  4. Quick Check:

    Failed test gate = pipeline stops [OK]
Hint: Failed test gate stops pipeline flow [OK]
Common Mistakes:
  • Assuming pipeline skips tests
  • Thinking pipeline restarts automatically
  • Believing deploy runs despite failed tests
4. You have this pipeline snippet:
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?
medium
A. The condition should explicitly check for true, e.g., tests_passed == true
B. The deploy stage is missing
C. The build stage is not defined
D. The test gate action should be 'stop_pipeline' instead of 'continue_pipeline'

Solution

  1. Step 1: Examine the test gate condition

    The condition uses tests_passed alone, which may not evaluate correctly if it's not a boolean.
  2. Step 2: Correct the condition syntax

    Explicitly checking tests_passed == true ensures the gate only passes when tests truly pass.
  3. Final Answer:

    The condition should explicitly check for true, e.g., tests_passed == true -> Option A
  4. Quick Check:

    Explicit condition check fixes gate logic [OK]
Hint: Use explicit boolean checks in test gates [OK]
Common Mistakes:
  • Ignoring condition syntax errors
  • Assuming missing stages cause gate failure
  • Confusing action names in test gates
5. A pipeline has these stages:
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?
hard
A. Deploy only if Unit Test gate passed, ignoring Integration Test
B. Skip Integration Test and deploy anyway
C. Stop the pipeline and prevent deployment
D. Restart the pipeline from Build stage automatically

Solution

  1. Step 1: Understand test gate purpose after Integration Test

    The gate ensures that integration tests pass before deployment to avoid faulty releases.
  2. Step 2: Determine correct pipeline behavior on gate failure

    If the Integration Test gate fails, the pipeline must stop to prevent deploying broken software.
  3. Final Answer:

    Stop the pipeline and prevent deployment -> Option C
  4. Quick Check:

    Failing test gate = stop deployment [OK]
Hint: Failing integration tests block deployment [OK]
Common Mistakes:
  • Ignoring integration test failures
  • Assuming automatic pipeline restart
  • Deploying despite failed test gates
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard