GCloud Module


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's Cloud SDK.

Currently, the module supports Datastore, Firestore, Pub/Sub and Spanner emulators. In order to use it, you should use the following classes:

  • DatastoreEmulatorContainer
  • FirestoreEmulatorContainer
  • PubSubEmulatorContainer
  • SpannerEmulatorContainer

Usage example

Running GCloud as a stand-in for Google Datastore during a test:

public DatastoreEmulatorContainer emulator = new DatastoreEmulatorContainer(

And how to start it:

public void testSimple() {
    DatastoreOptions options = DatastoreOptions.newBuilder()
    Datastore datastore = options.getService();

    Key key = datastore.newKeyFactory().setKind("Task").newKey("sample");
    Entity entity = Entity.newBuilder(key).set("description", "my description").build();

    assertThat(datastore.get(key).getString("description")).isEqualTo("my description");

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

testCompile "org.testcontainers:gcloud:1.15.0-rc2"