You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: TESTING.md
+17-8
Original file line number
Diff line number
Diff line change
@@ -13,19 +13,23 @@ This library provides tools to help write tests for code that uses the following
13
13
14
14
You can test against a temporary local Datastore by following these steps:
15
15
16
-
1. Start the local Datastore emulator before running your tests using `LocalDatastoreHelper`'s `start`method. This will create a temporary folder on your computer and bind a port for communication with the local datastore. There are two optional arguments for `start`: project ID and consistency. The consistency setting controls the fraction of Datastore writes that are immediately visible in global queries.
16
+
1. Start the local Datastore emulator before running your tests using `LocalDatastoreHelper`'s `create` and `start`methods. This will create a temporary folder on your computer and bind a port for communication with the local Datastore. There are two optional arguments for `create`: project ID and consistency. The consistency setting controls the fraction of Datastore writes that are immediately visible in global queries.
Note that you must call `start` before `options()`; otherwise, you will see an `IOException` regarding a refused connection.
32
+
29
33
3. Run your tests.
30
34
31
35
4. Stop the local datastore emulator by calling the `stop()` method, like so:
@@ -38,14 +42,19 @@ You can test against a temporary local Datastore by following these steps:
38
42
You can test against a remote Datastore emulator as well. To do this, set the `DatastoreOptions` project endpoint to the hostname of the remote machine, like the example below.
.projectId("my-project-id") // must match project ID specified on remote machine
43
47
.host("http://<hostname of machine>:<port>")
48
+
.authCredentials(AuthCredentials.noAuth())
44
49
.build();
45
50
Datastore localDatastore = options.service();
46
51
```
47
52
48
-
Note that the remote Datastore emulator must be running before your tests are run.
53
+
Note that the remote Datastore emulator must be running before running the code above. We recommend that you start the emulator on the remote machine using the [Google Cloud SDK](https://cloud.google.com/sdk/gcloud/reference/beta/emulators/datastore/) from command line, as shown below:
0 commit comments