DVA-C02 Deployment Practice Question
A developer uses AWS CodeBuild to run unit tests. The build succeeds but the tests fail. The developer wants to fail the build if tests fail. What should the developer do?
⚠ Common exam trap
A common mix-up: candidates think moving tests to a different phase (post_build) or enabling badges will fix the issue, but the core mechanism is the exit code of the command, not the phase or visual indicators.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Ensure the test command exits with a non-zero status on failure.
In CodeBuild, the build phase succeeds or fails based on the exit code of the commands in the buildspec. By default, if a test command exits with a non-zero status, CodeBuild marks the build as FAILED. Therefore, ensuring the test command exits with a non-zero status on failure is the correct approach to fail the build when tests fail.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Ensure the test command exits with a non-zero status on failure.
Why this is correct
AWS CodeBuild determines the success or failure of a build step based on the exit code of the executed command. A non-zero exit status, by convention in Unix-like systems, signals an error or failure. Therefore, configuring the test runner to return a non-zero exit code when tests fail will correctly propagate the test failure to CodeBuild, causing the entire build to fail and alert developers to issues. This mechanism is fundamental for automated CI/CD pipelines to accurately reflect the health of the codebase.
- ✗
Run tests in the post_build phase.
Why it's wrong here
Running tests in the post_build phase, while a common practice for executing tests after the application has been built, does not inherently change how AWS CodeBuild processes command exit codes. Regardless of the phase (e.g., build, post_build), CodeBuild will still mark a step as failed and subsequently the entire build as failed if a command within that step exits with a non-zero status. The choice of phase primarily dictates the order of operations, not the error handling mechanism.
- ✗
Set the command to always exit 0.
Why it's wrong here
Setting the test command to always exit with a status of 0 would prevent AWS CodeBuild from accurately identifying test failures. An exit code of 0 universally signifies successful execution, even if the tests themselves reported failures internally. This would cause CodeBuild to incorrectly mark the build as successful, masking critical issues and allowing faulty code to potentially proceed further in the deployment pipeline, undermining the purpose of automated testing.
- ✗
Enable build badges.
Why it's wrong here
Enabling build badges in AWS CodeBuild provides a visual indicator of the latest build status, typically embedded in source code repositories' README files or external dashboards. While useful for quick status checks and transparency, build badges are purely a reporting and visualization feature. They have no impact whatsoever on the underlying logic that determines whether a CodeBuild project fails or succeeds based on command exit codes or other build specifications.
Go deeper
Related to this question
About these practice questions
This DVA-C02 question is part of Courseiva's 724-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.