reporter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

File: internal/reporter/junit.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleReporter

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

ConsoleReporter prints test results to the console in a human-readable format. It supports both a standard and a verbose output mode.

func NewConsoleReporter

func NewConsoleReporter(verbose bool) *ConsoleReporter

NewConsoleReporter creates a new console reporter.

func (*ConsoleReporter) Render

func (c *ConsoleReporter) Render()

Render is a no-op for the console reporter.

func (*ConsoleReporter) SuiteFinished

func (c *ConsoleReporter) SuiteFinished()

SuiteFinished is a no-op for the console reporter as no final summary is needed.

func (*ConsoleReporter) SuiteStarted

func (c *ConsoleReporter) SuiteStarted(suite *models.TestSuite)

SuiteStarted prints a header indicating the start of a new test suite.

func (*ConsoleReporter) TestFinished

func (c *ConsoleReporter) TestFinished(result *models.TestResult)

TestFinished prints the result of a single test, including its status (PASS/FAIL) and duration. If the test failed, it also prints the errors.

type JUnitFailure

type JUnitFailure struct {
	Message string `xml:"message,attr"`
	Content string `xml:",cdata"`
}

type JUnitReporter

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

func NewJUnitReporter

func NewJUnitReporter(outputFile string) *JUnitReporter

func (*JUnitReporter) Render

func (r *JUnitReporter) Render()

func (*JUnitReporter) SuiteFinished

func (r *JUnitReporter) SuiteFinished()

func (*JUnitReporter) SuiteStarted

func (r *JUnitReporter) SuiteStarted(suite *models.TestSuite)

func (*JUnitReporter) TestFinished

func (r *JUnitReporter) TestFinished(result *models.TestResult)

type JUnitTestCase

type JUnitTestCase struct {
	XMLName   xml.Name      `xml:"testcase"`
	Name      string        `xml:"name,attr"`
	ClassName string        `xml:"classname,attr"`
	Time      float64       `xml:"time,attr"`
	Failure   *JUnitFailure `xml:"failure,omitempty"`
}

type JUnitTestSuite

type JUnitTestSuite struct {
	XMLName   xml.Name        `xml:"testsuite"`
	Name      string          `xml:"name,attr"`
	Tests     int             `xml:"tests,attr"`
	Failures  int             `xml:"failures,attr"`
	Time      float64         `xml:"time,attr"`
	TestCases []JUnitTestCase `xml:"testcase"`
}

type JUnitTestSuites

type JUnitTestSuites struct {
	XMLName xml.Name         `xml:"testsuites"`
	Suites  []JUnitTestSuite `xml:"testsuite"`
}

JUnit structure

type Reporter

type Reporter interface {
	// SuiteStarted is called when a new test suite begins.
	SuiteStarted(suite *models.TestSuite)

	// TestFinished is called after each test case is executed.
	TestFinished(result *models.TestResult)

	// SuiteFinished is called when a test suite has completed.
	SuiteFinished()

	// Render is called at the end of the entire test run to generate the final report.
	Render()
}

Reporter is the interface that all test reporters must implement. This allows for different output formats, such as console logging or JUnit XML.

Jump to

Keyboard shortcuts

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