junit

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package junit renders test results in the JUnit XML format that CI systems (CircleCI, Jenkins, GitLab, GitHub) render natively as test reports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(t *Testsuites) ([]byte, error)

Marshal renders the document with the XML declaration CI parsers expect.

func WriteFile

func WriteFile(path string, t *Testsuites) error

WriteFile renders the document to path.

Types

type Message

type Message struct {
	Text string `xml:"message,attr,omitempty"`
	Body string `xml:",chardata"`
}

Message carries a case's failure, error or skip reason.

type Testcase

type Testcase struct {
	Name      string   `xml:"name,attr"`
	Classname string   `xml:"classname,attr,omitempty"`
	File      string   `xml:"file,attr,omitempty"`
	Time      float64  `xml:"time,attr"`
	Failure   *Message `xml:"failure,omitempty"`
	Error     *Message `xml:"error,omitempty"`
	Skipped   *Message `xml:"skipped,omitempty"`
}

Testcase is one case: passing when Failure, Error and Skipped are all nil.

type Testsuite

type Testsuite struct {
	Name     string     `xml:"name,attr"`
	Tests    int        `xml:"tests,attr"`
	Failures int        `xml:"failures,attr"`
	Errors   int        `xml:"errors,attr"`
	Skipped  int        `xml:"skipped,attr"`
	Time     float64    `xml:"time,attr"`
	Cases    []Testcase `xml:"testcase"`
}

Testsuite is one group of test cases.

func (*Testsuite) AddCase

func (s *Testsuite) AddCase(c Testcase)

AddCase appends a case and folds it into the suite counts.

type Testsuites

type Testsuites struct {
	XMLName  xml.Name    `xml:"testsuites"`
	Name     string      `xml:"name,attr,omitempty"`
	Tests    int         `xml:"tests,attr"`
	Failures int         `xml:"failures,attr"`
	Errors   int         `xml:"errors,attr"`
	Skipped  int         `xml:"skipped,attr"`
	Time     float64     `xml:"time,attr"`
	Suites   []Testsuite `xml:"testsuite"`
}

Testsuites is the document root: one <testsuites> holding one suite per logical grouping of cases.

func (*Testsuites) AddSuite

func (t *Testsuites) AddSuite(suite Testsuite)

AddSuite appends a suite and folds its counts into the document totals.

Jump to

Keyboard shortcuts

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