runner

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package runner executes test.Test values under Go's native test framework and other test frameworks with a similar interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlessStrategy added in v0.2.4

type BlessStrategy int

BlessStrategy is a strategy for accepting failed test output as the new expectation, known as "blessing" the output.

const (
	// BlessAvailable is a [BlessStrategy] that instructs the user that blessing
	// may be activated by using the -aureus.bless flag on the command line.
	BlessAvailable BlessStrategy = iota

	// BlessEnabled is a [BlessStrategy] that explicitly enables blessing of
	// failed tests.
	BlessEnabled

	// BlessDisabled is a [BlessStrategy] that explicitly disables blessing of
	// failed tests.
	BlessDisabled
)

type FailerT added in v0.2.6

type FailerT interface {
	LoggerT
	SkipNow()
	Fail()
	Failed() bool
}

FailerT is the subset of the testing.TB that supports logging and failure reporting.

type Input added in v0.2.0

type Input interface {
	io.Reader

	// Language returns the language of the input value, if known, e.g. "json",
	// "yaml", etc.
	Language() string

	// Attributes returns a set of key-value pairs that provide additional
	// loader-specific information about the input.
	Attributes() map[string]string
}

Input is an interface for the input to a test.

type LoggerT added in v0.2.4

type LoggerT interface {
	Helper()
	Name() string
	Log(...any)
}

LoggerT is the subset of the testing.TB that supports logging only.

type Output added in v0.2.0

type Output interface {
	io.Writer

	// Language returns the expected language of the output value, if known,
	// e.g. "json", "yaml", etc.
	Language() string

	// Attributes returns a set of key-value pairs that provide additional
	// loader-specific information about the expected output.
	Attributes() map[string]string
}

Output is an interface for producing the output for a test.

type OutputGenerator

type OutputGenerator[T TestingT[T]] func(T, Input, Output) error

OutputGenerator produces the output of a specific test.

type Runner

type Runner[T TestingT[T]] struct {
	GenerateOutput  OutputGenerator[T]
	TrimSpace       bool // TODO: make this a loader concern
	BlessStrategy   BlessStrategy
	AssertionFilter func(test.Assertion) bool
	PackagePath     string
}

Runner executes tests under any test framework with an interface similar to Go's native *testing.T.

func (*Runner[T]) Run

func (r *Runner[T]) Run(t T, x test.Test)

Run makes the assertions described by all documents within a [TestSuite].

type TestingT

type TestingT[T any] interface {
	FailerT

	SkipNow()
	Fail()
	Failed() bool
	Run(string, func(T)) bool
}

TestingT is a constraint for types that are compatible with testing.T.

Jump to

Keyboard shortcuts

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