go-ethereum: github.com/ethereum/go-ethereum/internal/utesting Index | Files

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

Package Files

utesting.go

func CountFailures Uses

func CountFailures(rr []Result) int

CountFailures returns the number of failed tests in the result slice.

func Run Uses

func Run(test Test) (bool, string)

Run executes a single test.

type Result Uses

type Result struct {
    Name     string
    Failed   bool
    Output   string
    Duration time.Duration
}

Result is the result of a test execution.

func RunTests Uses

func RunTests(tests []Test, report io.Writer) []Result

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 Uses

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 Uses

func (t *T) Error(vs ...interface{})

Error is equivalent to Log followed by Fail.

func (*T) Errorf Uses

func (t *T) Errorf(format string, vs ...interface{})

Errorf is equivalent to Logf followed by Fail.

func (*T) Fail Uses

func (t *T) Fail()

Fail marks the test as having failed but continues execution.

func (*T) FailNow Uses

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 Uses

func (t *T) Failed() bool

Failed reports whether the test has failed.

func (*T) Fatal Uses

func (t *T) Fatal(vs ...interface{})

Fatal is equivalent to Log followed by FailNow.

func (*T) Fatalf Uses

func (t *T) Fatalf(format string, vs ...interface{})

Fatalf is equivalent to Logf followed by FailNow.

func (*T) Log Uses

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 Uses

func (t *T) Logf(format string, vs ...interface{})

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 Uses

type Test struct {
    Name string
    Fn   func(*T)
}

Test represents a single test.

func MatchTests Uses

func MatchTests(tests []Test, expr string) []Test

MatchTests returns the tests whose name matches a regular expression.

Package utesting imports 7 packages (graph) and is imported by 4 packages. Updated 2020-10-14. Refresh now. Tools for package owners.