google-cloud-java
google-cloud-java copied to clipboard
Support standard env vars for emulator testing
https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/environment_vars.py
What's the workaround for this until the env variable is supported?
Hi @kir-titievsky, we offer helper classes that allow you to start/stop/reset an emulator from your tests. For example the following code starts and uses the local datastore emulator:
// Use the default consistency setting of 0.9
LocalDatastoreHelper helper = LocalDatastoreHelper.create();
// or explicitly set the consistency
helper = LocalDatastoreHelper.create(0.6);
// Start the local Datastore emulator in a separate process
helper.start();
// Create and use a Datastore object with the options given by the LocalDatastoreHelper instance.
Datastore localDatastore = helper.options().service();
// Stop the emulator
helper.stop();
You can find more details in our TESTING readme. Does this help?