testingx

package
v0.1.52 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(t FatalReporter, err error, prefix string, args ...interface{})

Must allows the rtx.Must pattern within a unit test and will call t.Fatal if passed a non-nil error. The fatal message is specified as the prefix argument. If any further args are passed, then the prefix will be treated as a format string.

The main purpose of this function is to turn the common pattern of:

err := Func()
if err != nil {
    t.Fatalf("Helpful message (error: %v)", err)
}

into a simplified pattern of:

Must(t, Func(), "Helpful message")

This has the benefit of using fewer lines and verifying unit tests are "correct by inspection".

Types

type FatalReporter

type FatalReporter interface {
	Fatal(args ...interface{})
	Helper()
}

FatalReporter defines the interface for reporting a fatal test.

Jump to

Keyboard shortcuts

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