tbmock

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tbmock provides a mock testing.TB for verifying fail-fast behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpectFatal

func ExpectFatal(mtb *MockTB, fn func())

ExpectFatal calls fn and recovers if it triggered a MockTB fatal/skip.

Types

type FatalSentinel

type FatalSentinel struct{ Msg string }

FatalSentinel is panicked by MockTB to halt execution, mimicking testing.TB methods that call runtime.Goexit (Fatal, Fatalf, FailNow, Skip, Skipf, SkipNow). Recovered by ExpectFatal.

type MockTB

type MockTB struct {
	testing.TB // delegate to a real TB for methods we don't override

	FatalMsg string
	// contains filtered or unexported fields
}

MockTB wraps a real testing.TB so that un-overridden methods delegate safely, while intercepting all fail/skip methods via a panic sentinel.

func NewMockTB

func NewMockTB(t testing.TB) *MockTB

NewMockTB creates a new MockTB wrapping a real testing.TB.

func (*MockTB) Cleanup

func (f *MockTB) Cleanup(fn func())

func (*MockTB) Errorf

func (f *MockTB) Errorf(format string, args ...any)

func (*MockTB) FailNow

func (f *MockTB) FailNow()

func (*MockTB) Failed

func (f *MockTB) Failed() bool

Failed returns whether a fatal/skip method was called.

func (*MockTB) Fatal

func (f *MockTB) Fatal(args ...any)

func (*MockTB) Fatalf

func (f *MockTB) Fatalf(format string, args ...any)

func (*MockTB) Helper

func (f *MockTB) Helper()

func (*MockTB) Skip

func (f *MockTB) Skip(args ...any)

func (*MockTB) SkipNow

func (f *MockTB) SkipNow()

func (*MockTB) Skipf

func (f *MockTB) Skipf(format string, args ...any)

Jump to

Keyboard shortcuts

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