- A
Use Cloud Build's built-in test runner that automatically fails the build on test failure.
Why wrong: Cloud Build does not have a built-in test runner; it relies on the exit code of the command.
- B
Ensure the test command in the build step returns a non-zero exit code when tests fail.
Cloud Build treats any non-zero exit code as a failure, causing the build to fail.
- C
Create a custom builder that runs tests and emits a non-zero exit code on failure.
Why wrong: While a custom builder could work, it's overkill; standard images already return exit codes.
- D
Add a pre-build step that checks test results and triggers a build failure if needed.
Why wrong: Pre-build steps run before the main build; test results are not available at that point.
Quick Answer
The answer is to ensure the test command in the build step returns a non-zero exit code when tests fail. This is correct because Cloud Build evaluates each step’s success based on the exit code of the command executed inside its container; a non-zero exit code signals failure, causing Cloud Build to halt the pipeline and mark the build as failed. On the Google Professional Cloud Developer exam, this concept tests your understanding of how Cloud Build interprets step outcomes—a common trap is assuming you need a custom builder or a special `failure` condition, but the default behavior relies entirely on exit codes. For example, tools like `npm test` or `pytest` already return non-zero on failure, so no extra configuration is needed. Memory tip: think of exit codes as the build’s binary heartbeat—zero means alive, anything else means dead.
PCD Building and testing applications Practice Question
This PCD practice question tests your understanding of building and testing applications. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
A team uses Cloud Source Repositories for version control and Cloud Build for CI. The build configuration file (cloudbuild.yaml) includes a step that runs unit tests. The team wants to ensure that the build fails if any test fails. What should the developer do?
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 in the build step returns a non-zero exit code when tests fail.
Option B is correct because Cloud Build executes each step as a container, and the build step's success or failure is determined by the exit code of the command run inside that container. If the test command (e.g., `npm test` or `pytest`) returns a non-zero exit code when tests fail, Cloud Build will automatically mark that step as failed and stop the build. No special configuration or custom builder is required beyond ensuring the test command itself propagates the failure exit code.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use Cloud Build's built-in test runner that automatically fails the build on test failure.
Why it's wrong here
Cloud Build does not have a built-in test runner; it relies on the exit code of the command.
- ✓
Ensure the test command in the build step returns a non-zero exit code when tests fail.
Why this is correct
Cloud Build treats any non-zero exit code as a failure, causing the build to fail.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
Create a custom builder that runs tests and emits a non-zero exit code on failure.
Why it's wrong here
While a custom builder could work, it's overkill; standard images already return exit codes.
- ✗
Add a pre-build step that checks test results and triggers a build failure if needed.
Why it's wrong here
Pre-build steps run before the main build; test results are not available at that point.
Common exam traps
Common exam trap: answer the scenario, not the keyword
Cisco often tests the misconception that Cloud Build has a built-in test runner or that you need a custom builder to handle test failures, when in fact the standard exit code mechanism is all that is required.
Trap categories for this question
Command / output trap
Cloud Build does not have a built-in test runner; it relies on the exit code of the command.
Detailed technical explanation
How to think about this question
Under the hood, Cloud Build uses the exit code of the entrypoint or command in each step to determine success (0) or failure (non-zero). For example, `npm test` in a Node.js project will exit with code 1 if any test fails, which Cloud Build interprets as a step failure. A subtle behavior is that if you use a shell wrapper that masks the exit code (e.g., `npm test || true`), the build will succeed even if tests fail, which is a common real-world mistake.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Building and testing applications — study guide chapter
Learn the concepts, then practise the questions
- →
Building and testing applications practice questions
Targeted practice on this topic area only
- →
All PCD questions
500 questions across all exam domains
- →
Google Professional Cloud Developer study guide
Full concept coverage aligned to exam objectives
- →
PCD practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related PCD practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Designing highly scalable, available, and reliable cloud-native applications practice questions
Practise PCD questions linked to Designing highly scalable, available, and reliable cloud-native applications.
Building and testing applications practice questions
Practise PCD questions linked to Building and testing applications.
Deploying applications practice questions
Practise PCD questions linked to Deploying applications.
Integrating Google Cloud services practice questions
Practise PCD questions linked to Integrating Google Cloud services.
Managing application performance monitoring practice questions
Practise PCD questions linked to Managing application performance monitoring.
PCD fundamentals practice questions
Practise PCD questions linked to PCD fundamentals.
PCD scenario practice questions
Practise PCD questions linked to PCD scenario.
PCD troubleshooting practice questions
Practise PCD questions linked to PCD troubleshooting.
Practice this exam
Start a free PCD practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this PCD question test?
Building and testing applications — This question tests Building and testing applications — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Ensure the test command in the build step returns a non-zero exit code when tests fail. — Option B is correct because Cloud Build executes each step as a container, and the build step's success or failure is determined by the exit code of the command run inside that container. If the test command (e.g., `npm test` or `pytest`) returns a non-zero exit code when tests fail, Cloud Build will automatically mark that step as failed and stop the build. No special configuration or custom builder is required beyond ensuring the test command itself propagates the failure exit code.
What should I do if I get this PCD question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 11, 2026
This PCD practice question is part of Courseiva's free Google Cloud 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 PCD exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.