GCP - Professional Cloud Developer Study Guide

    2: Building and testing applications

    This chapter walks an application developer through the inner loop of life on Google Cloud, from setting up Cloud Workstations and Cloud Code with the gcloud CLI emulators, to producing signed container images with Cloud Build and Artifact Registry, and closing with unit and integration test patterns that run under Cloud Build with AI-assisted authoring. Every section is grounded in the configuration knobs an exam question can target.

    Learning Objectives

    By the end of this chapter, you will be able to:

    • Configure a local and remote development environment using the Cloud SDK, Cloud Code, Gemini Cloud Assist, Cloud Shell, and Cloud Workstations, and run gcloud-CLI-driven emulators of Pub/Sub, Firestore, Bigtable, and Spanner for offline unit tests.
    • Wire an integrated development environment to Application Default Credentials, AI coding assistants, and Model Context Protocol servers without leaking long-lived secrets.
    • Author Cloud Build configurations that build and push container images to Artifact Registry, manage build pools, cache layers, and tag images deterministically.
    • Configure SLSA-aligned build provenance, Artifact Analysis vulnerability scanning, and Binary Authorization attestors so that only verified images deploy to Cloud Run and GKE.
    • Generate unit tests with AI coding assistants while keeping test isolation, faked clocks, and emulator endpoints under control.
    • Run integration test suites under Cloud Build using private worker pools, sidecar emulators, and conditional triggers.

    Executive Summary

    • The gcloud CLI ships in-process emulators for Pub/Sub, Spanner, Bigtable, Firestore, and the Datastore mode of Firestore; pointing your client library at the emulator endpoint avoids round trips to production projects during unit tests and keeps CI runs deterministic.
    • Cloud Workstations gives every developer an identical, IAM-controlled container image with the Cloud SDK and Cloud Code preinstalled, while Cloud Shell stays the right answer for short, ephemeral admin sessions.
    • Cloud Build runs each step as a container, supports private worker pools inside a VPC, and produces SLSA Build Level 3 provenance that Binary Authorization can attest before any Cloud Run or GKE deploy admits the image.
    • AI coding assistants speed up unit test authoring through Gemini Code Assist and MCP servers, but the developer still owns assertion correctness, fixture isolation, and licence hygiene; an assistant is never authoritative for a Cloud API contract that has not been verified against the official documentation.

    Assumptions

    • The reader is fluent with the design choices framed previously around Compute Engine, GKE Standard, GKE Autopilot, Cloud Run services, Cloud Run jobs, and Cloud Run functions and does not need those terms redefined.
    • Code samples assume the Cloud SDK is installed and gcloud config configurations are already separated by environment (dev, staging, prod) so commands do not target the wrong project.
    • The chapter targets practitioners building application code in Go, Java, Node.js, or Python with Cloud Client Libraries; the same patterns apply to other supported runtimes.
    • Region references stay generic (for example us-central1, europe-west1) and are not tied to any single deployment.

    Sections in this chapter

    1. Free
    2. Free with account
    3. Free with account
    4. Free with account