package utesting
import "github.com/ethereum/go-ethereum/internal/utesting"
Package utesting provides a standalone replacement for package testing.
This package exists because package testing cannot easily be embedded into a standalone go program. It provides an API that mirrors the standard library testing API.
Index ¶
- func CountFailures(rr []Result) int
- func Run(test Test) (bool, string)
- type Result
- func RunTAP(tests []Test, report io.Writer) []Result
- func RunTests(tests []Test, report io.Writer) []Result
- type T
- func (t *T) Error(vs ...interface{})
- func (t *T) Errorf(format string, vs ...interface{})
- func (t *T) Fail()
- func (t *T) FailNow()
- func (t *T) Failed() bool
- func (t *T) Fatal(vs ...interface{})
- func (t *T) Fatalf(format string, vs ...interface{})
- func (t *T) Helper()
- func (t *T) Log(vs ...interface{})
- func (t *T) Logf(format string, vs ...interface{})
- type Test
Functions ¶
func CountFailures ¶
CountFailures returns the number of failed tests in the result slice.
func Run ¶
Run executes a single test.
Types ¶
type Result ¶
Result is the result of a test execution.
func RunTAP ¶
RunTAP runs the given tests and writes Test Anything Protocol output to the report writer.
func RunTests ¶
RunTests executes all given tests in order and returns their results. If the report writer is non-nil, a test report is written to it in real time.
type T ¶
type T struct {
// contains filtered or unexported fields
}
T is the value given to the test function. The test can signal failures and log output by calling methods on this object.
func (*T) Error ¶
func (t *T) Error(vs ...interface{})
Error is equivalent to Log followed by Fail.
func (*T) Errorf ¶
Errorf is equivalent to Logf followed by Fail.
func (*T) Fail ¶
func (t *T) Fail()
Fail marks the test as having failed but continues execution.
func (*T) FailNow ¶
func (t *T) FailNow()
FailNow marks the test as having failed and stops its execution by calling runtime.Goexit (which then runs all deferred calls in the current goroutine).
func (*T) Failed ¶
Failed reports whether the test has failed.
func (*T) Fatal ¶
func (t *T) Fatal(vs ...interface{})
Fatal is equivalent to Log followed by FailNow.
func (*T) Fatalf ¶
Fatalf is equivalent to Logf followed by FailNow.
func (*T) Helper ¶
func (t *T) Helper()
Helper exists for compatibility with testing.T.
func (*T) Log ¶
func (t *T) Log(vs ...interface{})
Log formats its arguments using default formatting, analogous to Println, and records the text in the error log.
func (*T) Logf ¶
Logf formats its arguments according to the format, analogous to Printf, and records the text in the error log. A final newline is added if not provided.
type Test ¶
Test represents a single test.
func MatchTests ¶
MatchTests returns the tests whose name matches a regular expression.
Source Files ¶
- Version
- v1.15.11 (latest)
- Published
- May 5, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 1 day ago –
Tools for package owners.