Skip to content

Commit bdc3978

Browse files
committed
docs: update test.md for unified test runner
1 parent 30cb1cc commit bdc3978

File tree

1 file changed

+53
-34
lines changed

1 file changed

+53
-34
lines changed

contributing/test.md

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,94 @@
11
# Test
22

3-
## Commands
3+
## Test Runner
44

5-
### Using go test
5+
The test suite uses `scripts/test.sh` as the unified test runner. It provides consistent behavior across different commands with support for [gotestsum](https://github.com/gotestyourself/gotestsum) (recommended) or plain `go test`.
66

7-
1. Run all tests
7+
### Runner Behavior
88

9-
```sh
10-
go test ./...
11-
```
9+
By default, the script auto-detects the available runner:
1210

13-
2. Run unit tests
11+
1. If `RUNNER` env var is set, use that explicitly
12+
2. If `gotestsum` is installed, use it (with automatic retries for flaky tests)
13+
3. Otherwise, fall back to `go test`
14+
15+
To install gotestsum (recommended):
1416

1517
```sh
16-
go test ./... -short
18+
go install gotest.tools/gotestsum@latest
1719
```
1820

19-
3. Run integration tests
21+
To force a specific runner:
2022

2123
```sh
22-
go test ./... -run "Integration"
24+
RUNNER=go ./scripts/test.sh test # Force go test
25+
RUNNER=gotestsum ./scripts/test.sh test # Force gotestsum
2326
```
2427

25-
### Using Make (requires gotestsum)
28+
## Commands
2629

27-
The Makefile uses [gotestsum](https://github.com/gotestyourself/gotestsum) which provides better output formatting and automatic retries for flaky tests.
30+
### Using the Test Script
2831

2932
```sh
30-
# Install gotestsum first
31-
go install gotest.tools/gotestsum@latest
32-
```
33+
# Run all tests (unit + integration)
34+
./scripts/test.sh test
3335

34-
1. Run all tests
36+
# Run unit tests only (uses -short flag)
37+
./scripts/test.sh unit
3538

36-
```sh
37-
make test
39+
# Run end-to-end tests
40+
./scripts/test.sh e2e
41+
42+
# Run full suite with all backend combinations
43+
./scripts/test.sh full
3844
```
3945

40-
2. Run unit tests
46+
### Using Make
47+
48+
The Makefile targets delegate to `scripts/test.sh`:
4149

4250
```sh
43-
make test/unit
51+
make test # ./scripts/test.sh test
52+
make test/unit # ./scripts/test.sh unit
53+
make test/e2e # ./scripts/test.sh e2e
54+
make test/full # ./scripts/test.sh full
4455
```
4556

46-
3. Run integration tests
57+
### Using go test Directly
4758

4859
```sh
49-
make test/integration
60+
go test ./... # All tests
61+
go test ./... -short # Unit tests only
62+
go test ./... -run "Integration" # Integration tests
5063
```
5164

52-
#### Make Options
65+
## Environment Variables
66+
67+
| Variable | Description | Default |
68+
|----------|-------------|---------|
69+
| `TEST` | Package(s) to test | `./internal/...` |
70+
| `RUN` | Filter tests by name pattern | (none) |
71+
| `TESTARGS` | Additional arguments to pass to test command | (none) |
72+
| `TESTINFRA` | Set to `1` to use persistent test infrastructure | (none) |
73+
| `TESTCOMPAT` | Set to `1` to run full backend compatibility suite | (none) |
74+
| `TESTREDISCLUSTER` | Set to `1` to enable Redis cluster tests | (none) |
75+
| `RUNNER` | Force test runner: `gotestsum` or `go` | auto-detect |
5376

54-
1. To test specific package
77+
### Examples
5578

5679
```sh
80+
# Test specific package
5781
TEST='./internal/services/api' make test
58-
```
5982

60-
2. To run specific tests
61-
62-
```sh
83+
# Run specific tests
6384
RUN='TestJWT' make test
64-
```
65-
66-
3. To pass additional options
6785

68-
```sh
86+
# Pass additional options
6987
TESTARGS='-v' make test
70-
```
7188

72-
Keep in mind you can't use `RUN` along with `make test/integration` as it already uses `-run` option. However, since you're already specifying which test to run, we assume this is a non-issue.
89+
# Combine options
90+
RUN='TestListTenant' TEST='./internal/models' TESTINFRA=1 make test
91+
```
7392

7493
## Coverage
7594

0 commit comments

Comments
 (0)