Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/Just-maple/go-junit-report/v2

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/Just-maple/go-junit-report/v2

  • v2.0.0-20220825032330-dbb230a5393c
  • Source
  • Go
  • Socket score

Version published
Created
Source

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:

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/v2@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.

FlagDescription
-in fileread go test log from file
-iocopycopy input to stdout; can only be used in conjunction with -out
-no-xml-headerdo not print xml header
-out filewrite XML report to file
-package-name namespecify a default package name to use if output does not contain a package name
-parser parserspecify the parser to use, available parsers are: gotest (default), gojson
-p key=valueadd property to generated report; properties should be specified as key=value
-set-exit-codeset exit code to 1 if tests failed
-subtest-modeset subtest mode, modes are: ignore-parent-results, exclude-parents
-versionprint version and exit

Changelog

v2.0.0

  • Support for parsing go test -json output.
  • Distinguish between build/runtime errors and test failures.
  • JUnit report now includes output for all tests and benchmarks, and global output that doesn't belong to any test.
  • Use full Go package name in generated report instead of only last path segment.
  • Add support for reading skipped/failed benchmarks.
  • Add -subtest-mode flag to exclude or ignore results of subtest parent tests.
  • Add -in and -out flags for specifying input and output files respectively.
  • Add -iocopy flag to copy stdin directly to stdout.
  • Add -prop flags to set key/value properties in generated report.
  • Add -parser flag to switch between regular go test (default) and go test -json parsing.
  • Output in JUnit XML is written in <![CDATA[]]> tags for improved readability.
  • Add hostname, timestamp and id attributes to JUnit XML.
  • Improve accuracy of benchmark time calculation and update formatting in report.
  • No longer strip leading whitespace from test output.
  • The formatter and parser packages have been replaced with junit and parser/gotest packages respectively.
  • Add support for parsing lines longer than 64KiB.
  • The JUnit errors/failures attributes are now required fields.
  • Drop support for parsing pre-Go1.13 test output.
  • Deprecate -go-version flag.

Contributing

See CONTRIBUTING.md.

FAQs

Package last updated on 25 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc