|
1 | 1 | # go-junit-report
|
2 | 2 |
|
3 |
| -Converts `go test` output to an xml report, suitable for applications that |
4 |
| -expect junit xml reports (e.g. [Jenkins](http://jenkins-ci.org)). |
| 3 | +go-junit-report is a tool that converts [`go test`] output to an XML report, |
| 4 | +suitable for applications that expect JUnit-style XML reports (e.g. |
| 5 | +[Jenkins](http://jenkins-ci.org)). |
| 6 | + |
| 7 | +The test output [parser] and JUnit report [formatter] are also available as Go |
| 8 | +packages. |
5 | 9 |
|
6 | 10 | [![Build Status][travis-badge]][travis-link]
|
7 |
| -[![Report Card][report-badge]][report-link] |
8 | 11 |
|
9 |
| -## Installation |
| 12 | +## Install from package (recommended) |
| 13 | + |
| 14 | +Pre-built packages for Windows, macOS and Linux are found on the [Releases] |
| 15 | +page. |
| 16 | + |
| 17 | +## Install from source |
10 | 18 |
|
11 |
| -Go version 1.2 or higher is required. Install or update using the `go get` |
12 |
| -command: |
| 19 | +Download and install the latest stable version from source by running: |
13 | 20 |
|
14 | 21 | ```bash
|
15 |
| -go get -u github.com/jstemmer/go-junit-report |
| 22 | +go install github.com/jstemmer/go-junit-report@latest |
16 | 23 | ```
|
17 | 24 |
|
18 | 25 | ## Usage
|
19 | 26 |
|
20 |
| -go-junit-report reads the `go test` verbose output from standard in and writes |
21 |
| -junit compatible XML to standard out. |
| 27 | +go-junit-report reads the full `go test` output from stdin and writes JUnit |
| 28 | +compatible XML to stdout. In order to capture build errors as well as test |
| 29 | +output, redirect both stdout and stderr to go-junit-report. |
22 | 30 |
|
23 | 31 | ```bash
|
24 | 32 | go test -v 2>&1 | go-junit-report > report.xml
|
25 | 33 | ```
|
26 | 34 |
|
27 |
| -Note that it also can parse benchmark output with `-bench` flag: |
| 35 | +Parsing benchmark output is also supported, for example: |
| 36 | + |
28 | 37 | ```bash
|
29 | 38 | go test -v -bench . -count 5 2>&1 | go-junit-report > report.xml
|
30 | 39 | ```
|
31 | 40 |
|
32 |
| -## Contribution |
| 41 | +If you want go-junit-report to exit with a non-zero exit code when it encounters |
| 42 | +build errors or test failures, set the `-set-exit-code` flag. |
33 | 43 |
|
34 |
| -Create an Issue and discuss the fix or feature, then fork the package. |
35 |
| -Clone to github.com/jstemmer/go-junit-report. This is necessary because go import uses this path. |
36 |
| -Fix or implement feature. Test and then commit change. |
37 |
| -Specify #Issue and describe change in the commit message. |
38 |
| -Create Pull Request. It can be merged by owner or administrator then. |
| 44 | +Run `go-junit-report -help` for a list of all supported flags. |
39 | 45 |
|
40 |
| -### Run Tests |
| 46 | +## Contributing |
41 | 47 |
|
42 |
| -```bash |
43 |
| -go test |
44 |
| -``` |
| 48 | +See [CONTRIBUTING.md]. |
45 | 49 |
|
| 50 | +[`go test`]: https://pkg.go.dev/cmd/go#hdr-Test_packages |
| 51 | +[parser]: https://pkg.go.dev/github.com/jstemmer/go-junit-report/parser |
| 52 | +[formatter]: https://pkg.go.dev/github.com/jstemmer/go-junit-report/formatter |
46 | 53 | [travis-badge]: https://travis-ci.org/jstemmer/go-junit-report.svg?branch=master
|
47 | 54 | [travis-link]: https://travis-ci.org/jstemmer/go-junit-report
|
48 |
| -[report-badge]: https://goreportcard.com/badge/github.com/jstemmer/go-junit-report |
49 |
| -[report-link]: https://goreportcard.com/report/github.com/jstemmer/go-junit-report |
| 55 | +[Releases]: https://github.com/jstemmer/go-junit-report/releases |
| 56 | +[CONTRIBUTING.md]: https://github.com/jstemmer/go-junit-report/blob/master/CONTRIBUTING.md |
0 commit comments