Signed-off-by: Anda Xu <anda.xu@docker.com>
| ... | ... |
@@ -47,6 +47,24 @@ Bugs fixes should include a unit test case which exercises the bug. |
| 47 | 47 |
A bug fix may also include new assertions in an existing integration tests for the |
| 48 | 48 |
API endpoint. |
| 49 | 49 |
|
| 50 |
+### Integration tests environment considerations |
|
| 51 |
+ |
|
| 52 |
+When adding new tests or modifying existing test under `integration/`, testing |
|
| 53 |
+environment should be properly considered. `skip.If` from |
|
| 54 |
+[gotest.tools/skip](https://godoc.org/gotest.tools/skip) can be used to make the |
|
| 55 |
+test run conditionally. Full testing environment conditions can be found at |
|
| 56 |
+[environment.go](https://github.com/moby/moby/blob/cb37987ee11655ed6bbef663d245e55922354c68/internal/test/environment/environment.go) |
|
| 57 |
+ |
|
| 58 |
+Here is a quick example. If the test needs to interact with a docker daemon on |
|
| 59 |
+the same host, the following condition should be checked within the test code |
|
| 60 |
+ |
|
| 61 |
+```go |
|
| 62 |
+skip.If(t, testEnv.IsRemoteDaemon()) |
|
| 63 |
+// your integration test code |
|
| 64 |
+``` |
|
| 65 |
+ |
|
| 66 |
+If a remote daemon is detected, the test will be skipped. |
|
| 67 |
+ |
|
| 50 | 68 |
## Running tests |
| 51 | 69 |
|
| 52 | 70 |
To run the unit test suite: |