Skip to content

Commit

Permalink
Some README updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jan 25, 2019
1 parent 90bf791 commit 257abc0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
41 changes: 25 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ variable.
gotestsum --format short-verbose
```

The supported formats are:
Supported formats:
* `dots` - output one character per test.
* `short` (default) - output a line for each test package.
* `standard-quiet` - the default `go test` format.
Expand All @@ -47,10 +47,16 @@ Have a suggestion for some other format? Please open an issue!

### Summary

After the tests are done a summary of the test run is printed.
A summary of the test run is printed after the test output.

```
DONE 101 tests[, 3 skipped][, 2 failures][, 1 error] in 0.103s
```

The summary includes:
* A count of the tests run, skipped, failed, build errors, and elapsed time.
* Test output of all failed and skipped tests, and any build errors.
* A count of: tests run, tests skipped, tests failed, and package build errors.
* Elapsed time including time to build.
* Test output of all failed and skipped tests, and any package build errors.

To disable parts of the summary use `--no-summary section`.

Expand All @@ -72,29 +78,30 @@ gotestsum --no-summary=output

### JUnit XML

In addition to the normal test output you can write a JUnit XML file for
integration with CI systems. Write a file using the `--junitfile` flag or
the `GOTESTSUM_JUNITFILE` environment variable.
When the `--junitfile` flag or `GOTESTSUM_JUNITFILE` environment variable are set
to a file path `gotestsum` will write a test report, in JUnit XML format, to the file.
This file can be used to integrate with CI systems.

```
gotestsum --junitfile unit-tests.xml
```

### JSON file output

In addition to the normal test output you can write a line-delimited JSON
file with all the [test2json](https://golang.org/cmd/test2json/#hdr-Output_Format)
output that was written by `go test --json`. This file can be used to calculate
statistics about the test run.
When the `--jsonfile` flag or `GOTESTSUM_JSONFILE` environment variable are set
to a file path `gotestsum` will write a line-delimited JSON file with all the
[test2json](https://golang.org/cmd/test2json/#hdr-Output_Format)
output that was written by `go test --json`. This file can be used to compare test
runs, or find flaky tests.

```
gotestsum --jsonfile test-output.log
```

### Custom `go test` command

By default `gotestsum` runs `go test --json ./...`. You can change this by
specifying additional positional arguments after a `--`. You can change just the
By default `gotestsum` runs tests using the command `go test --json ./...`. You
can change the command with positional arguments after a `--`. You can change just the
test directory value (which defaults to `./...`) by setting the `TEST_DIRECTORY`
environment variable.

Expand All @@ -105,7 +112,7 @@ Example: set build tags
gotestsum -- -tags=integration ./...
```

Example: run only a single package
Example: run tests in a single package
```
gotestsum -- ./io/http
```
Expand All @@ -121,8 +128,10 @@ gotestsum --raw-command -- ./scripts/run_tests.sh
```

Note: when using `--raw-command` you must ensure that the stdout produced by
the script only contains the `test2json` output. Any stderr produced will
be considered an error (to match the behaviour of `go test --json`).
the script only contains the `test2json` output. Any stderr produced by the script
will be considered an error (this behaviour is necessary because package build errors
are only reported by writting to stderr, not the `test2json` stdout). Any stderr
produced by tests is not considered an error (it will be in the `test2json` stdout).

Example: using `TEST_DIRECTORY`
```
Expand Down
2 changes: 1 addition & 1 deletion testjson/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (e *Execution) add(event TestEvent) {
Elapsed: elapsedDuration(event.Elapsed),
})
// Remove test output once a test passes, it wont be used
pkg.output[event.Test] = nil
delete(pkg.output, event.Test)
}
}

Expand Down

0 comments on commit 257abc0

Please sign in to comment.