Bird
Raised Fist0
Testing Fundamentalstesting~10 mins

Why CI/CD integrates testing into delivery in Testing Fundamentals - Test Your Understanding

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a CI/CD pipeline step that runs tests automatically.

Testing Fundamentals
pipeline {
  stages {
    stage('Test') {
      steps {
        sh '[1]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Anpm test
Bnpm run build
Cnpm deploy
Dnpm install
Attempts:
3 left
💡 Hint
Common Mistakes
Using build or deploy commands instead of test
Forgetting to run tests in the pipeline
2fill in blank
medium

Complete the code to add a test stage that runs only if the build stage succeeds.

Testing Fundamentals
pipeline {
  stages {
    stage('Build') {
      steps {
        sh 'make build'
      }
    }
    stage('Test') {
      when {
        [1] 'Build'
      }
      steps {
        sh 'make test'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abranch
Benvironment
Cstage
Dinput
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'branch' or 'environment' instead of 'stage'
Not adding any condition to run tests after build
3fill in blank
hard

Fix the error in the test command to ensure tests run correctly in the CI/CD pipeline.

Testing Fundamentals
steps {
  sh '[1]'
}
Drag options to blanks, or click blank then click option'
Anpm test --watch
Bnpm test --ci
Cnpm test --silent
Dnpm test --coverage
Attempts:
3 left
💡 Hint
Common Mistakes
Using watch mode which waits for changes
Not using CI-specific flags causing pipeline to hang
4fill in blank
hard

Fill both blanks to create a test report file and archive it after tests run.

Testing Fundamentals
steps {
  sh 'pytest > [1]'
  archiveArtifacts '[2]'
}
Drag options to blanks, or click blank then click option'
Atest-results.txt
Btest-results.xml
Attempts:
3 left
💡 Hint
Common Mistakes
Using different filenames for output and archive
Archiving a non-existent file
5fill in blank
hard

Fill all three blanks to define a pipeline that builds, tests, and deploys only if tests pass.

Testing Fundamentals
pipeline {
  stages {
    stage('Build') {
      steps {
        sh '[1]'
      }
    }
    stage('Test') {
      steps {
        sh '[2]'
      }
    }
    stage('Deploy') {
      when {
        [3] 'Test'
      }
      steps {
        sh 'deploy.sh'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Amake build
Bmake test
Cstage
Dmake deploy
Attempts:
3 left
💡 Hint
Common Mistakes
Deploying without checking test success
Mixing up commands for build and test

Practice

(1/5)
1. Why is testing integrated into the CI/CD pipeline?
easy
A. To avoid writing code
B. To slow down the delivery process
C. To increase manual work for developers
D. To find problems early and improve software quality

Solution

  1. Step 1: Understand the purpose of CI/CD testing

    Testing in CI/CD helps catch bugs early before software reaches users.
  2. Step 2: Recognize the benefit of early problem detection

    Finding issues early improves software quality and reduces costly fixes later.
  3. Final Answer:

    To find problems early and improve software quality -> Option D
  4. Quick Check:

    Early testing = better quality [OK]
Hint: Testing in CI/CD finds bugs early to improve quality [OK]
Common Mistakes:
  • Thinking testing slows delivery
  • Believing testing is optional
  • Assuming testing increases manual work
2. Which of the following is the correct way to add a test stage in a CI/CD YAML pipeline?
easy
A. steps: - build - deploy - test
B. stages: - build - test - deploy
C. jobs: - deploy - test - build
D. phases: - test - build - deploy

Solution

  1. Step 1: Identify correct CI/CD pipeline syntax

    Most CI/CD tools use 'stages' to define order: build, test, deploy.
  2. Step 2: Check the order of stages

    Testing should come after build and before deploy for proper flow.
  3. Final Answer:

    stages: - build - test - deploy -> Option B
  4. Quick Check:

    Stages order: build, test, deploy [OK]
Hint: Stages define order: build, test, then deploy [OK]
Common Mistakes:
  • Mixing steps and stages keywords
  • Placing test after deploy
  • Using unsupported keywords like phases
3. In a CI/CD pipeline, why is it important to run automated tests before deployment?
easy
A. To increase manual testing effort
B. To delay the deployment process intentionally
C. To catch bugs early and prevent faulty code from reaching users
D. To skip code reviews

Solution

  1. Step 1: Understand the role of automated tests in CI/CD

    Automated tests verify code correctness quickly and reliably before deployment.
  2. Step 2: Recognize the impact on software quality and user experience

    Running tests early prevents bugs from reaching users, improving reliability.
  3. Final Answer:

    To catch bugs early and prevent faulty code from reaching users -> Option C
  4. Quick Check:

    Tests before deploy = fewer bugs in production [OK]
Hint: Tests before deploy catch bugs early [OK]
Common Mistakes:
  • Thinking tests delay deployment on purpose
  • Confusing automated tests with manual effort
  • Believing tests replace code reviews
4. Consider this simplified CI/CD pipeline snippet:
stages:
  - build
  - test

build_job:
  stage: build
  script:
    - echo "Building..."
test_job:
  stage: test
  script:
    - exit 1

What will happen when this pipeline runs?
medium
A. The build job runs, then the test job fails, stopping the pipeline
B. Both build and test jobs succeed
C. The test job runs before the build job
D. The pipeline ignores the test job failure and continues

Solution

  1. Step 1: Analyze job order by stages

    Build stage runs first, then test stage runs after build completes.
  2. Step 2: Check test job script

    Test job script exits with code 1, which means failure.
  3. Final Answer:

    The build job runs, then the test job fails, stopping the pipeline -> Option A
  4. Quick Check:

    Failing test stops pipeline [OK]
Hint: Exit code 1 means test failure stops pipeline [OK]
Common Mistakes:
  • Assuming test runs before build
  • Thinking pipeline ignores failures
  • Believing all jobs always succeed
5. A CI/CD pipeline has this test stage:
test_job:
  stage: test
  script:
    - pytest tests/
  only:
    - main
    - develop

Why might tests not run on a feature branch?
medium
A. Because the 'only' keyword limits runs to 'main' and 'develop' branches
B. Because pytest is not installed
C. Because the test stage is missing
D. Because the script syntax is incorrect

Solution

  1. Step 1: Understand 'only' keyword effect

    'only' restricts job runs to specified branches: main and develop.
  2. Step 2: Check branch context

    Feature branches are not listed, so tests won't run there.
  3. Final Answer:

    Because the 'only' keyword limits runs to 'main' and 'develop' branches -> Option A
  4. Quick Check:

    'only' limits branches [OK]
Hint: 'only' controls which branches run jobs [OK]
Common Mistakes:
  • Assuming tests run on all branches
  • Blaming missing pytest without checking config
  • Ignoring branch filters in pipeline
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