json2junit

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package json2junit converts JSON Go test output to JUnit XML format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(w io.Writer, r io.Reader) error

Convert reads Go test JSON and writes converted JUnit XML.

func ConvertFile

func ConvertFile(out, in string) error

ConvertFile reads a Go test JSON file and creates a JUnit XML file with converted content. Creates the directory containing the target file if necessary.

Types

type Converter

type Converter struct {
	// contains filtered or unexported fields
}

A Converter holds the state of a JSON-to-JUnit conversion. It implements io.WriteCloser; call Write with JSON test output, then Close. The JUnit output is written to the writer w that was passed to NewConverter.

The JSON input is buffered, so the caller can write it in arbitrary size chunks that don't have to align with the JSON lines. The JUnit output is not written immediately, but chunked into test suites which are written to w as soon as they are complete.

func NewConverter

func NewConverter(w io.Writer) *Converter

NewConverter returns a "JSON to JUnit" converter. Writes on the returned writer are written as JUnit to w, with minimal delay.

func (*Converter) Close

func (c *Converter) Close() error

Close marks the end of the go test output.

func (*Converter) Write

func (c *Converter) Write(b []byte) (int, error)

Write writes a JSON test entry to the writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL