docs/modules/gcloud.md
!!! note This module is INCUBATING. While it is ready for use and operational in the current version of Testcontainers, it is possible that it may receive breaking changes in the future. See our contributing guidelines for more information on our incubating modules policy.
Testcontainers module for the Google Cloud Platform's Cloud SDK.
Currently, the module supports BigQuery, Bigtable, Datastore, Firestore, Spanner, and Pub/Sub emulators. In order to use it, you should use the following classes:
| Class | Container Image |
|---|---|
| BigQueryEmulatorContainer | ghcr.io/goccy/bigquery-emulator |
| BigtableEmulatorContainer | gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators |
| DatastoreEmulatorContainer | gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators |
| FirestoreEmulatorContainer | gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators |
| SpannerEmulatorContainer | gcr.io/cloud-spanner-emulator/emulator |
| PubSubEmulatorContainer | gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators |
Start BigQuery Emulator during a test:
<!--codeinclude-->Starting a BigQuery Emulator container inside_block:emulatorContainer
<!--/codeinclude--> <!--codeinclude-->Creating BigQuery Client inside_block:bigQueryClient
<!--/codeinclude-->Start Bigtable Emulator during a test:
<!--codeinclude-->Starting a Bigtable Emulator container inside_block:emulatorContainer
<!--/codeinclude-->Create a test Bigtable table in the Emulator:
<!--codeinclude-->Create a test table inside_block:createTable
<!--/codeinclude-->Test against the Emulator:
<!--codeinclude-->Testing with a Bigtable Emulator container inside_block:testWithEmulatorContainer
<!--/codeinclude-->Start Datastore Emulator during a test:
<!--codeinclude-->Starting a Datastore Emulator container inside_block:creatingDatastoreEmulatorContainer
<!--/codeinclude-->And test against the Emulator:
<!--codeinclude-->Testing with a Datastore Emulator container inside_block:startingDatastoreEmulatorContainer
<!--/codeinclude-->See more examples:
Start Firestore Emulator during a test:
<!--codeinclude-->Starting a Firestore Emulator container inside_block:emulatorContainer
<!--/codeinclude-->And test against the Emulator:
<!--codeinclude-->Testing with a Firestore Emulator container inside_block:testWithEmulatorContainer
<!--/codeinclude-->See more examples:
Start Spanner Emulator during a test:
<!--codeinclude-->Starting a Spanner Emulator container inside_block:emulatorContainer
<!--/codeinclude-->Create a test Spanner Instance in the Emulator:
<!--codeinclude-->Create a test Spanner instance inside_block:createInstance
<!--/codeinclude-->Create a test Database in the Emulator:
<!--codeinclude-->Creating a test Spanner database inside_block:createDatabase
<!--/codeinclude-->And test against the Emulator:
<!--codeinclude-->Testing with a Spanner Emulator container inside_block:testWithEmulatorContainer
<!--/codeinclude-->See more examples:
Start Pub/Sub Emulator during a test:
<!--codeinclude-->Starting a Pub/Sub Emulator container inside_block:emulatorContainer
<!--/codeinclude-->Create a test Pub/Sub topic in the Emulator:
<!--codeinclude-->Create a test topic inside_block:createTopic
<!--/codeinclude-->Create a test Pub/Sub subscription in the Emulator:
<!--codeinclude-->Create a test subscription inside_block:createSubscription
<!--/codeinclude-->And test against the Emulator:
<!--codeinclude-->Testing with a Pub/Sub Emulator container inside_block:testWithEmulatorContainer
<!--/codeinclude-->See more examples:
Add the following dependency to your pom.xml/build.gradle file:
=== "Gradle"
groovy testImplementation "org.testcontainers:testcontainers-gcloud:{{latest_version}}"
=== "Maven"
xml <dependency> <groupId>org.testcontainers</groupId> <artifactId>testcontainers-gcloud</artifactId> <version>{{latest_version}}</version> <scope>test</scope> </dependency>