Using Cloud Build to build a Docker image, you must run unit and integration tests and have the build history show which stage failed. What should you do?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a Cloud Build build config file with separate cloud builder steps to compile and execute unit and integration tests..
Why this is the answer
The correct approach is to create a Cloud Build build config file with separate cloud builder steps for compilation, unit tests, and integration tests. This allows Cloud Build to execute each stage independently. If a unit test fails, Cloud Build will stop at that step, mark the build as failed, and the build history will clearly indicate which specific step (e.g., "unit-tests") caused the failure. Adding RUN commands directly to the Dockerfile for tests is not ideal because tests are build-time concerns, not runtime concerns for the final image. This would also make the image larger and less efficient. A single build step for all tests would obscure the exact point of failure. Spawning separate Cloud Build pipelines for tests adds unnecessary complexity and overhead compared to using distinct steps within a single pipeline.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed