report

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package report turns a test runner's output into typed failures.

This is the difference between an agent that fixes its own test and one that flails. Handed raw stdout, a model has to guess at the format, and it guesses differently each time; handed {file, line, message} it can open the file and edit the line.

There is no cross-language standard for this, and it is worth being blunt that there isn't. JUnit XML is a de facto format with real dialect drift -- pytest ships a junit_family setting precisely because implementations disagree -- and the native JSON formats are each single-ecosystem. So the approach is one small internal shape plus a parser per format, built against output captured from the real runners rather than from documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Failure

type Failure struct {
	// Name is the test's name, as the runner reports it.
	Name string `json:"name"`
	// Suite is the enclosing class, file, or package.
	Suite string `json:"suite,omitempty"`
	// File and Line locate the failure. Empty when the runner does not say
	// and the message does not reveal it; never guessed.
	File string `json:"file,omitempty"`
	Line int    `json:"line,omitempty"`
	// Message is the assertion message, trimmed to something an agent can read
	// without a full stack trace.
	Message string `json:"message"`
	// Output is the untruncated failure text, when it differs from Message.
	Output string `json:"output,omitempty"`
}

Failure is one failing test, located.

type Result

type Result struct {
	Total    int           `json:"total"`
	Passed   int           `json:"passed"`
	Failed   int           `json:"failed"`
	Skipped  int           `json:"skipped"`
	Duration time.Duration `json:"duration_ms"`
	Failures []Failure     `json:"failures"`
}

Result is a parsed test run.

func Parse

func Parse(format manifest.ReportFormat, r io.Reader) (*Result, error)

Parse dispatches on the manifest's declared format.

func ParseGoJSON

func ParseGoJSON(r io.Reader) (*Result, error)

ParseGoJSON reads the newline-delimited event stream from `go test -json`.

It is a stream rather than a report file, which is why it is parsed incrementally: a long suite reports progress as it goes instead of only at the end.

func ParseJUnit

func ParseJUnit(r io.Reader) (*Result, error)

ParseJUnit reads JUnit XML, tolerating the dialects real runners emit.

func ParseJestJSON

func ParseJestJSON(r io.Reader) (*Result, error)

ParseJestJSON reads the JSON that `jest --json` and `vitest --reporter=json` emit; Vitest documents its reporter as Jest-compatible, so one parser serves both.

type Status

type Status string

Status is the outcome of one test.

const (
	Passed  Status = "passed"
	Failed  Status = "failed"
	Skipped Status = "skipped"
)

Jump to

Keyboard shortcuts

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