nerdexam
Google

PROFESSIONAL-CLOUD-DEVELOPER · Question #105

You are developing an application that reads credit card data from a Pub/Sub subscription. You have written code and completed unit testing. You need to test the Pub/Sub integration before deploying…

The correct answer is D. Create a service to publish messages, and deploy the Pub/Sub emulator. Publish a standard set. The correct approach is to deploy the Pub/Sub emulator and publish a standard set of messages for testing. The Pub/Sub emulator replicates Pub/Sub behavior locally without connecting to Google Cloud, making it ideal for pre-deployment integration testing. Using a standard…

Building and testing applications

Question

You are developing an application that reads credit card data from a Pub/Sub subscription. You have written code and completed unit testing. You need to test the Pub/Sub integration before deploying to Google Cloud. What should you do?

Options

  • ACreate a service to publish messages, and deploy the Pub/Sub emulator. Generate random
  • BCreate a service to publish messages to your application. Collect the messages from Pub/Sub in
  • CCreate a service to publish messages, and deploy the Pub/Sub emulator. Collect the messages
  • DCreate a service to publish messages, and deploy the Pub/Sub emulator. Publish a standard set

How the community answered

(23 responses)
  • A
    4% (1)
  • C
    4% (1)
  • D
    91% (21)

Explanation

The correct approach is to deploy the Pub/Sub emulator and publish a standard set of messages for testing. The Pub/Sub emulator replicates Pub/Sub behavior locally without connecting to Google Cloud, making it ideal for pre-deployment integration testing. Using a standard, predefined set of messages (rather than random ones) ensures tests are deterministic and repeatable - you can verify that your application correctly processes known inputs and produces expected outputs. Option A (random messages) is non-deterministic, making it hard to validate correctness. Option B doesn't use the emulator, meaning it would require actual GCP connectivity and incur costs. Option C (collecting messages from Pub/Sub) still doesn't verify that the application processes them correctly in a controlled way. Predictable test data is essential for meaningful integration testing.

Topics

#Pub/Sub#Local Testing#Emulator#Application Development

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice