Code Monkey home page Code Monkey logo

go-junit-report's Introduction

go-junit-report

go-junit-report is a tool that converts go test output to a JUnit compatible XML report, suitable for use with applications such as Jenkins.

Build status

The test output parser and JUnit XML report generator are also available as Go packages. This can be helpful if you want to create your own custom JUnit reports for example. See the package documentation on pkg.go.dev for more information:

Install from package (recommended)

Pre-built packages for Windows, macOS and Linux are found on the Releases page.

Install from source

Download and install the latest stable version from source by running:

go install github.com/jstemmer/go-junit-report@latest

Usage

By default, go-junit-report reads go test -v output generated by the standard library testing package from stdin and writes a JUnit XML report to stdout.

Go build and runtime errors are also supported, but this requires that stderr is redirected to go-junit-report as well.

Typical use looks like this:

go test -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml

More examples

JSON produced by go test -json is supported by the gojson parser. Note that stderr still needs to be redirected to go-junit-report in order for build errors to be detected. For example:

go test -json 2>&1 | go-junit-report -parser gojson > report.xml

Go benchmark output is also supported. The following example runs benchmarks for the package in the current directory and uses the -out flag to write the output to a file called report.xml.

go test -v -bench . -count 5 2>&1 | go-junit-report -out report.xml

The -iocopy flag copies stdin directly to stdout, which is helpful if you want to see what was sent to go-junit-report. The following example reads test input from a file called tests.txt, copies the input to stdout and writes the output to a file called report.xml.

go-junit-report -in tests.txt -iocopy -out report.xml

Flags

Run go-junit-report -help for a list of all supported flags.

Flag Description
-in file read go test log from file
-iocopy copy input to stdout; can only be used in conjunction with -out
-no-xml-header do not print xml header
-out file write XML report to file
-package-name name specify a default package name to use if output does not contain a package name
-parser parser specify the parser to use, available parsers are: gotest (default), gojson
-p key=value add property to generated report; properties should be specified as key=value
-set-exit-code set exit code to 1 if tests failed
-version print version and exit

Contributing

See CONTRIBUTING.md.

go-junit-report's People

Contributors

jstemmer avatar ikarishinjieva avatar brittinator avatar posener avatar nickpalmer avatar ixdy avatar ascandella avatar jmillikin-stripe avatar johnschnake avatar liggitt avatar mark-rushakoff avatar mattdelco avatar themichaellai avatar nmiyake avatar pascalbourdier avatar nullbio avatar benzaita avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.