!!! 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:
Starting a BigQuery Emulator container inside_block:emulatorContainer
Creating BigQuery Client inside_block:bigQueryClient
Start Bigtable Emulator during a test:
Starting a Bigtable Emulator container inside_block:emulatorContainer
Create a test Bigtable table in the Emulator:
Create a test table inside_block:createTable
Test against the Emulator:
Testing with a Bigtable Emulator container inside_block:testWithEmulatorContainer
Start Datastore Emulator during a test:
Starting a Datastore Emulator container inside_block:creatingDatastoreEmulatorContainer
And test against the Emulator:
Testing with a Datastore Emulator container inside_block:startingDatastoreEmulatorContainer
See more examples:
Start Firestore Emulator during a test:
Starting a Firestore Emulator container inside_block:emulatorContainer
And test against the Emulator:
Testing with a Firestore Emulator container inside_block:testWithEmulatorContainer
See more examples:
Start Spanner Emulator during a test:
Starting a Spanner Emulator container inside_block:emulatorContainer
Create a test Spanner Instance in the Emulator:
Create a test Spanner instance inside_block:createInstance
Create a test Database in the Emulator:
Creating a test Spanner database inside_block:createDatabase
And test against the Emulator:
Testing with a Firestore Emulator container inside_block:testWithEmulatorContainer
See more examples:
Start Pub/Sub Emulator during a test:
Starting a Pub/Sub Emulator container inside_block:emulatorContainer
Create a test Pub/Sub topic in the Emulator:
Create a test topic inside_block:createTopic
Create a test Pub/Sub subscription in the Emulator:
Create a test subscription inside_block:createSubscription
And test against the Emulator:
Testing with a Pub/Sub Emulator container inside_block:testWithEmulatorContainer
See more examples:
Add the following dependency to your pom.xml
/build.gradle
file:
=== "Gradle"
groovy testImplementation "org.testcontainers:gcloud:{{latest_version}}"
=== "Maven"
xml <dependency> <groupId>org.testcontainers</groupId> <artifactId>gcloud</artifactId> <version>{{latest_version}}</version> <scope>test</scope> </dependency>