To run automated tests with Google Cloud Build, add a build step that invokes your project’s test command in a container with the required runtime and tools. Put that step before packaging, publishing, or deployment steps so a failed test stops the build before those later actions. You can run the build manually or configure a repository trigger to start it after a change.
How Cloud Build runs tests
Cloud Build reads a YAML or JSON build configuration and executes its steps in containers. A test is an ordinary build step: choose an image with the runtime and tooling your project needs, then invoke the same test command you would run locally or in another CI environment. The same configuration can include dependency setup, static analysis, integration tests, and later build or release steps.
Steps run serially by default. That makes order meaningful: place tests before any step that should happen only when they pass. Choose a runtime image and dependency process that match your project; the examples below use Python, Node.js, and Go, but they are not the only supported options.
Add a test step to cloudbuild.yaml
Create a cloudbuild.yaml at the project root. This minimal example runs Python tests and fails the build if pytest exits unsuccessfully:
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest']
Replace the image and command with the runtime image, dependency installation, and test command your project requires. For reproducible builds, choose and maintain an appropriate versioned image rather than relying on a floating latest tag. If tests require dependencies, install them in an earlier step or use an image that already contains them.
Use the test command for your language
Python
Run pytest as a module. To generate a JUnit XML report as well as the usual test output, add pytest’s report option:
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest', '--junitxml=${SHORT_SHA}_test_log.xml']
This invokes python -m pytest. Ensure the image or an earlier setup step provides pytest and the project’s other dependencies.
Node.js
If the project’s package.json defines a test script, install dependencies and run it in a Node.js image:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
steps:
- name: 'node'
entrypoint: 'npm'
args: ['install']
- name: 'node'
entrypoint: 'npm'
args: ['test']
Use the dependency installation method appropriate to your project and lockfile. The important part is that the test step runs the project’s actual test script and preserves its exit status.
Go
The basic Go test command is go test. To produce JUnit XML, Google’s example pipes verbose test output through go-junit-report and uses -set-exit-code so a test failure remains a failing build step. The formatter must be available in the chosen environment:
steps:
- name: 'golang'
entrypoint: 'bash'
args:
- '-c'
- 'go test -v ./... 2>&1 | go-junit-report -set-exit-code > ${SHORT_SHA}_test_log.xml'
Adapt the package pattern and formatter installation to your repository. The explicit exit-code behavior matters when output is piped: without it, a shell pipeline can report the formatter’s status instead of the test command’s status.
Keep tests as a gate for later build steps
Because steps run serially by default, put the test step before container image construction, publication, or deployment when those actions depend on passing tests. A nonzero test command should fail the step and therefore prevent subsequent steps from running. Take care with shell pipelines, wrappers, or scripts that might swallow or replace the test process’s exit status.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
For example, this ordering runs tests before building an image:
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest']
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'example-image', '.']
Replace the image-building step with the packaging or release action you actually use. Do not place a release step before the test gate if it must be blocked by failures.
Generate and store a JUnit XML report
Report generation and report storage are separate choices. A test command can write JUnit XML locally in the build workspace; to retain that file outside the build, also declare it as a Cloud Storage artifact. For example, extend the Python configuration like this:
steps:
- name: 'python'
entrypoint: 'python'
args: ['-m', 'pytest', '--junitxml=${SHORT_SHA}_test_log.xml']
artifacts:
objects:
location: 'gs://${_BUCKET_NAME}/'
paths:
- '${SHORT_SHA}_test_log.xml'
Before relying on upload, create the destination bucket and ensure the build’s service account has permission to write objects there. A generated XML file is not automatically uploaded just because the test command created it. JUnit XML is useful when you want a portable results artifact; it is not required to run tests. If you do not need a separate report file, inspect the test output in the build logs instead.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Run a build manually
After adding the configuration, submit a build from the project directory with the Google Cloud CLI:
gcloud builds submit --config=cloudbuild.yaml .
The final . supplies the current directory as the build source. A manual submission is useful for an ad hoc run or for checking the configuration before connecting a repository trigger. To supply a user-defined substitution such as the bucket variable in the report example, pass it explicitly:
gcloud builds submit --config=cloudbuild.yaml
--substitutions=_BUCKET_NAME=my-test-reports .
Use built-in substitutions such as $PROJECT_ID or user-defined substitutions for values that vary by build. Treat substitutions as configuration values, not as a place to put secrets; the substitution mechanism itself does not establish secret handling.
Run tests automatically with a repository trigger
For continuous integration, create a Cloud Build trigger connected to your repository and configure it to respond to the repository event you want, such as a push to a branch. The trigger uses the build configuration and can also define substitutions for values that vary in trigger builds. This lets the same test-first configuration run automatically when the selected change event occurs.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
- Connect or select the repository for the trigger.
- Choose the event and branch condition, for example a push to a particular branch.
- Point the trigger at
cloudbuild.yamlin the repository. - Set any required trigger substitutions, such as a report bucket name.
- Save the trigger, then make a matching repository change to start a build.
Exact console labels and trigger setup details can change. After a trigger runs, open Cloud Build History and select the build to inspect its status, steps, and logs.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Diagnose a failed test build
Start with the failing step in the build details and its log output. Check the command, runtime environment, and—if you configured a report artifact—the upload destination separately.
- Runtime or tool missing: The selected image may not contain the language version, test runner, or report formatter the command expects. Choose a suitable image or install the missing tool as part of the build.
- Dependencies unavailable: Add the project’s dependency installation step or use the appropriate prebuilt environment. Check that installation runs before tests.
- Wrong test command: Confirm that the command matches the project’s scripts or test framework. For Node.js, for example,
npm testdepends on a test script being defined inpackage.json. - Build succeeds despite failed tests: Inspect shell pipelines and wrapper scripts for lost exit codes. When piping Go test output through a formatter, use explicit failure propagation such as
-set-exit-code. - Report file missing: Verify the test command actually writes the path declared under
artifacts.objects.paths, and that the path is relative to the build workspace as expected. - Report upload fails: Confirm the bucket exists, the configured location is correct, and the build service account can write objects to it.
- Trigger does not start a build: Check that the repository event and branch match the trigger conditions and that the trigger points to the intended configuration file.
Use ScreenshotNeo when a test needs a website screenshot
Cloud Build runs your automated test commands; it does not itself provide a website screenshot API. If a separate test or workflow needs to capture a URL, ScreenshotNeo is a screenshot API and MCP server that can return an image or PDF. For an API call from your own script or build step, keep the access key in your secret-handling setup and install the requests package in the environment first.
Or skip the browser setup
Instead of installing and operating a browser for a URL capture, call the ScreenshotNeo API:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation. It accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. ScreenshotNeo also has an MCP server with screenshot, page-info, and PDF-capture tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month with no card.
Choose the right run and reporting setup
- Manual submission: Use it for an ad hoc check or to validate a configuration before automating it.
- Repository trigger: Use it when a matching repository event should start tests automatically.
- Build logs only: Keep the configuration simpler when console output is enough to diagnose failures.
- JUnit XML plus Cloud Storage: Generate and upload a report when you need a results file retained separately from the build logs.
For current configuration and language-specific details, consult Google Cloud’s Cloud Build documentation, including its build configuration, unit-test, trigger, and substitution guides.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

