Documentation
¶
Index ¶
- type Assertion
- func (a *Assertion) Add(sub *Assertion) *Assertion
- func (a *Assertion) Benchmark() func(*testing.B)
- func (a *Assertion) Error() *Assertion
- func (a *Assertion) Fatal() *Assertion
- func (a *Assertion) Log(args ...any) *Assertion
- func (a *Assertion) Logf(tmpl string, args ...any) *Assertion
- func (a *Assertion) Metadata(md *dt.Pairs[string, any]) *Assertion
- func (a *Assertion) Queit() *Assertion
- func (a *Assertion) Run(t testing.TB)
- func (a *Assertion) Test() func(*testing.T)
- func (a *Assertion) That(t is.That) *Assertion
- func (a *Assertion) Verbose() *Assertion
- func (a *Assertion) With(name string, op func(ensure *Assertion)) *Assertion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertion ¶
type Assertion struct {
// contains filtered or unexported fields
}
Assertion, produced by the ensure.That() constructor is a chainable interface for annotating rich assertions, as a complement to the fun/assert and fun/assert/check libraries. Use ensure.That() forms to annotate
func That ¶
That constructs a new Assertion with the provided check, as in:
ensure.That(is.True(1 == 1)).Run(t)
func (*Assertion) Benchmark ¶
Benchmark creates a sub-benchrmark function, which is suitable for use as an argument to b.Run().
func (*Assertion) Error ¶
Error uses t.Error or b.Error assertions, which mean that the assertion is "continue-on-error" and will not abort the execution of the test in the case of a failure.
func (*Assertion) Fatal ¶
Fatal, the default, means that the assertion has "abort-on-error" semantics, and will cause the test to fail when the assertion fails. If there are subtests, they will always run before the test aborts.
func (*Assertion) Log ¶
Logs adds a message that is printed on failure in quiet mode, and unconditionally in verbose mode. Operates generally like t.Log() or fmt.Sprint().
func (*Assertion) Logf ¶
Logf adds a message that is printed on failure in quiet mode, and unconditionally in verbose mode. Operates like t.Logf or fmt.Sprintf.
func (*Assertion) Metadata ¶
Metadata adds structured logging pairs, which can be constructed using the is.Plist().Add(k,v) constructor and chaining.
Each pair is logged as it's own Log statement.
func (*Assertion) Queit ¶
Quiet toggles the logging behavior to be "quiet" (e.g. only, log in the case of that the Assertion fails.) This is the default.
func (*Assertion) Test ¶
Test creates a test function, which is suitable for use as an argument to t.Run() as a subtest.
func (*Assertion) That ¶
That sets a new assertion handler function, overriding (potentially) the assertion created when the Assertion was created. If the assertion has been run, this operation is always a noop.
func (*Assertion) Verbose ¶
Verbose toggles the logging behavior to log all messages even when the test succeeds.
func (*Assertion) With ¶
With creates a subtest that is un-conditionally executed after the assertions main check runs.
Subtests are always run after the root of their "parent" tasks, are run unconditionally in the order they were added.
It is invalid and will panic if you call .Run() on the assertion provided to the With() function.