Documentation
¶
Overview ¶
Package tbmock provides a mock testing.TB for verifying fail-fast behavior.
Index ¶
- func ExpectFatal(mtb *MockTB, fn func())
- type FatalSentinel
- type MockTB
- func (f *MockTB) Cleanup(fn func())
- func (f *MockTB) Errorf(format string, args ...any)
- func (f *MockTB) FailNow()
- func (f *MockTB) Failed() bool
- func (f *MockTB) Fatal(args ...any)
- func (f *MockTB) Fatalf(format string, args ...any)
- func (f *MockTB) Helper()
- func (f *MockTB) Skip(args ...any)
- func (f *MockTB) SkipNow()
- func (f *MockTB) Skipf(format string, args ...any)
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.
Click to show internal directories.
Click to hide internal directories.