Question 350 of 500
Building and testing applicationshardMultiple SelectObjective-mapped

Quick Answer

The correct answer is to write integration tests that use the Cloud Functions Emulator or a test project, combined with unit tests that mock external services and a local framework for rapid feedback. This approach is essential because unit tests isolate your function’s logic by mocking dependencies like databases or APIs, ensuring fast, deterministic results without incurring live infrastructure costs or side effects. On the Google Professional Cloud Developer exam, this question tests your understanding of the testing pyramid applied to serverless—many candidates mistakenly pick only unit tests, forgetting that integration testing with the emulator validates real HTTP triggers and event bindings. A common trap is assuming the emulator replaces all unit tests, but it actually complements them by catching deployment-specific issues. Remember the mnemonic: “Mock the call, emulate the fall”—unit tests mock external calls, while the emulator catches integration failures before they hit production.

PCD Building and testing applications Practice Question

This PCD practice question tests your understanding of building and testing applications. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. 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 developer wants to ensure their Cloud Function is reliable. Which three testing practices should they follow? (Choose three.)

Question 1hardmulti select
Full question →

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

Write unit tests that mock external services

Option A is correct because unit tests should mock external services (like databases or APIs) to isolate the function's logic and avoid dependencies on live infrastructure. This ensures tests are fast, deterministic, and do not incur costs or side effects from actual service calls.

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.

  • Write unit tests that mock external services

    Why this is correct

    Unit tests verify logic in isolation, increasing confidence in code correctness.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Use the Cloud Functions Framework to run the function locally

    Why this is correct

    Local testing with the framework allows quick iterations without cloud deployment.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Write integration tests that use the Cloud Functions Emulator or a test project

    Why this is correct

    Integration tests verify interactions with external services in a controlled environment.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Deploy the function to production for integration testing

    Why it's wrong here

    Production deployment for testing is risky and may affect users.

  • Perform load testing using a Cloud Scheduler job that invokes the function frequently

    Why it's wrong here

    Load testing is for performance, not reliability; it may cause higher costs and is not a best practice for reliability testing.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Cisco often tests the distinction between deployment strategies and testing practices, where candidates mistakenly treat production deployment or scheduler-based invocation as valid testing methods instead of using isolated, controlled environments.

Detailed technical explanation

How to think about this question

The Cloud Functions Framework (option B) allows local execution via the `functions-framework` command, which starts an HTTP server that emulates the Cloud Functions environment, enabling rapid debugging without deployment. The Cloud Functions Emulator (option C) provides a local or test-project environment that mimics the actual runtime, including authentication and event triggers, which is critical for validating end-to-end behavior before production. Unit tests (option A) that mock external services rely on frameworks like `unittest.mock` in Python or `sinon` in Node.js to simulate HTTP responses, preventing flaky tests due to network latency or service unavailability.

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 startup's cloud architect reviews their monthly bill and notices costs are higher than expected for a long-running batch job. Switching from on-demand instances to Reserved Instances — or using Spot/Preemptible VMs — can reduce compute costs by up to 72 %. Questions like this test whether you understand the tradeoffs between commitment, flexibility, and cost across cloud pricing models.

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.

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.

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: Write unit tests that mock external services — Option A is correct because unit tests should mock external services (like databases or APIs) to isolate the function's logic and avoid dependencies on live infrastructure. This ensures tests are fast, deterministic, and do not incur costs or side effects from actual service calls.

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more ways this is tested on PCD

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer is using Cloud Functions and wants to ensure that their testing environment mirrors production as closely as possible. Which approach should they take?

easy
  • A.Use Cloud Build to run tests before deployment
  • B.Run all tests in Cloud Shell
  • C.Deploy to a staging Cloud Function and run tests against it
  • D.Use the Functions Framework with a simulated production event

Why D: The Functions Framework is a local emulator that allows developers to run Cloud Functions locally with the same invocation context and event triggers as in production. By using the Functions Framework with a simulated production event, you can test your function's behavior, including event data parsing and response handling, without deploying to any cloud environment, ensuring the testing environment mirrors production as closely as possible.

Last reviewed: Jun 25, 2026

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.

Loading comments…

Sign in to join the discussion.

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.