logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

go-junit-report - convert Go test output to JUnit XML

Description

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

       By default, go-junit-report reads gotest-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 2E<gt>&1 ./... | go-junit-report -set-exit-code E<gt> report.xml

       Alternatively, go-junit-report can consume JSON output of gotest. In this case, stderr still needs to be
       redirected for build errors to be detected.

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

       The -iocopy flag copies stdin directly to stdout, which is useful to still be able to see the gotest
       output.

           go test -v 2E<gt>&1 ./... | go-junit-report -set-exit-code -iocopy -out report.xml

Exit Status

       If  go-junit-report  encounters  an  error  during  its operation, or doesn’t understand its command-line
       options, 2 is returned.

       If the input logs indicate the tests failed, and -set-exit-code is specified, 1 is returned.

       Otherwise, 0 is returned.

Name

       go-junit-report - convert Go test output to JUnit XML

Options

-infile
           Read the log from file. If not specified, stdin is used.

       -outfile
           Write XML report to file. If not specified, stdout is used.

       -iocopy
           Copy  input  to stdout. Can only be used in conjunction with -out.  This is useful if you want to see
           what was sent to go-junit-report.

       -no-xml-header
           Do not print the XML header.

       -pkey=value
           Add a key=value property to generated report. Repeat this flag to add multiple properties.

       -package-namename
           Specify a default package name to use if test log does not contain a package name.

       -parserstring
           Set input parser type: gotest or gojson (default: gotest).

       -set-exit-code
           Set exit code to 1 if tests failed.

       -subtest-modemode
           Set subtest mode: ignore-parent-results  (subtest  parents  always  pass),  exclude-parents  (subtest
           parents are excluded from the report).

       -help
           Print a summary of command-line options.

       -version
           Print the go-junit-report version.

       -debug.print-events
           print events generated by the go test parser

       -go-versionstring
           (deprecated, use -prop) the value to use for the go.version property in the generated XML

Synopsis

go-junit-report [-infile] [-outfile] [options...]

       go-junit-report-versiongo-junit-report-help

See Also