https://github.com/becheran/go-testreport
Generate a markdown test report from the go json test result
https://github.com/becheran/go-testreport
github-actions go markdown report unittest
Last synced: 2 months ago
JSON representation
Generate a markdown test report from the go json test result
- Host: GitHub
- URL: https://github.com/becheran/go-testreport
- Owner: becheran
- License: mit
- Created: 2022-12-27T19:24:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-22T16:57:19.000Z (4 months ago)
- Last Synced: 2025-03-29T10:51:18.473Z (3 months ago)
- Topics: github-actions, go, markdown, report, unittest
- Language: Go
- Homepage:
- Size: 129 KB
- Stars: 32
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Test Report
[](https://github.com/becheran/go-testreport/actions/workflows/go.yml)
[![Go Report Card][go-report-image]][go-report-url]
[![PRs Welcome][pr-welcome-image]][pr-welcome-url]
[![License][license-image]][license-url]
[![GHAction][gh-action-image]][gh-action-url][license-url]: https://github.com/becheran/go-testreport/blob/main/LICENSE
[license-image]: https://img.shields.io/badge/License-MIT-brightgreen.svg
[go-report-image]: https://img.shields.io/badge/go%20report-A+-brightgreen.svg?style=flat
[go-report-url]: https://goreportcard.com/report/github.com/becheran/go-testreport
[pr-welcome-image]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[pr-welcome-url]: https://github.com/becheran/go-testreport/blob/main/CONTRIBUTING.md
[gh-action-image]: https://img.shields.io/badge/Get-GH_Action-blue
[gh-action-url]: https://github.com/marketplace/actions/golang-test-reportGenerate a markdown test report from the go json test result.
Matches perfectly with [github job summaries]( https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/) to visualize test results:

The default output sorts the tests by failing and slowest execution time.
## Install
### Go
Install via the go install command:
``` sh
go install github.com/becheran/go-testreport@latest
```### Binaries
Or use the pre-compiled binaries for Linux, Windows, and Mac OS from the [github releases page](https://github.com/becheran/go-testreport/releases).
## Usage
Run the following command to get a list of all available command line options:
``` sh
go-testreport -h
```### Input and Output
When `-input` and `-output` is not set, the stdin stream will be used and return the result will be written to stdout. Will exit with a non zero exit code if at least one test failed:
``` sh
go test ./... -json | go-testreport > result.html
```Use the `-input` and `-output` file to set files for the input and output. Will always exit with zero also if tests fail:
``` sh
go-testreport -input result.json -output result.html
```### Templates
Customize by providing a own [template file](https://pkg.go.dev/text/template). See also the [default markdown template](./src/report/templates/md.tmpl) which is used if the `-template` argument is left empty. With the `vars` options custom dynamic values can be passed to the template from the outside which can be resolved within the template:
``` sh
go test ./... -json | go-testreport -template=./html.tmpl -vars="Title:Test Report Linux" > $GITHUB_STEP_SUMMARY
```### GitHub Actions
The [Golang Test Report](https://github.com/marketplace/actions/golang-test-report) from the marketplace can be used to integrate the go-testreport tool into an GitHub workflow:
``` yaml
- name: Test
run: go test ./... -json > report.json
- name: Report
uses: becheran/go-testreport@main
with:
input: report.json
```