Q85 — AWS DVA-C02 Ch.1
Question 85 of 100 | ← Chapter 1
A developer is using AWS CodePipeline as the CI/CD mechanism for a web application. The developer added unit tests to programmatically verify application code functionality. Unit tests generate a test report showing results for each individual check. The developer now wants to automatically execute these tests within the CI/CD pipeline. Which solution meets this requirement with the least operational effort?
- A. Write a Git pre-commit hook to run tests before each commit. Ensure every developer working on the project installs the pre-commit hook locally. Review the test report and resolve issues before pushing changes to AWS CodeCommit.
- B. Add a new stage to the pipeline. Use AWS CodeBuild as the provider. Add the new stage after the stage that deploys code revisions to the test environment. Write a build specification that fails the CodeBuild stage if any test fails. Use CodeBuild’s test reporting feature to integrate reports with the CodeBuild console. View test results in CodeBuild and resolve issues.
- C. Add a new stage to the pipeline. Use AWS CodeBuild as the provider. Add the new stage before the stage that deploys code revisions to the test environment. Write a build specification that fails the CodeBuild stage if any test fails. Use CodeBuild’s test reporting feature to integrate reports with the CodeBuild console. View test results in CodeBuild and resolve issues. ✓
- D. Add a new stage to the pipeline. Use Jenkins as the provider. Configure CodePipeline to use Jenkins to run unit tests. Write a Jenkinsfile that fails the stage if any test fails. Use Jenkins’ test reporting plugin to integrate reports with the Jenkins dashboard. View test results in Jenkins and resolve issues.
Correct Answer: C. Add a new stage to the pipeline. Use AWS CodeBuild as the provider. Add the new stage before the stage that deploys code revisions to the test environment. Write a build specification that fails the CodeBuild stage if any test fails. Use CodeBuild’s test reporting feature to integrate reports with the CodeBuild console. View test results in CodeBuild and resolve issues.
Explanation
Option C satisfies both key requirements: (1) tests run *before* deployment (enabling fast failure feedback), and (2) leverages native AWS services (CodeBuild) to minimize integration overhead. CodeBuild’s built-in test reporting eliminates third-party tooling (e.g., Jenkins in D) and avoids manual local enforcement (A). Option B places testing *after* deployment, violating CI/CD best practices. Thus, C is optimal.