Documentation
¶
Overview ¶
Package testingx provides set of utilities for tests and runnable examples.
Index ¶
- type AssertTB
- type E
- func (e *E) Chdir(dir string)
- func (e *E) Cleanup(f func())
- func (e *E) Context() context.Context
- func (e *E) Error(args ...any)
- func (e *E) Errorf(format string, args ...interface{})
- func (e *E) Fail()
- func (e *E) FailNow()
- func (e *E) Failed() bool
- func (e *E) Fatal(args ...any)
- func (e *E) Fatalf(format string, args ...any)
- func (e *E) Helper()
- func (e *E) Log(args ...any)
- func (e *E) Logf(format string, args ...any)
- func (e *E) Name() string
- func (e *E) Setenv(key, value string)
- func (e *E) Skip(args ...any)
- func (e *E) SkipNow()
- func (e *E) Skipf(format string, args ...any)
- func (e *E) Skipped() bool
- func (e *E) TempDir() string
- type PrintingTBE
- type RequireTB
- type TB
- type TBE
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssertTB ¶
type AssertTB interface { Helper() Errorf(format string, args ...interface{}) }
AssertTB is a subinterface of testing.TB that fulfills the needs of assert package from testify library, but also includes the Helper method. This package also provides an implementation of this interface, called testingx.E, that can be used in runnable examples.
type E ¶
type E struct {
Verbose bool
}
E is emulating a testing.TB for runnable examples. It is useful to show usage of the library elements dedicated to tests, how they can be used. Unfortunately, testing.TB cannot be implemented because it has a private method on the interface. This is why it's preferable to use one of testingx or own declared interfaces as argument types instead.
WARNING: This struct is still under development, and still some parts are not implemented completely.
func (*E) Cleanup ¶
func (e *E) Cleanup(f func())
Cleanup is a testing.TB Cleanup method implementation for runnable examples.
func (*E) Error ¶
Error is a testing.TB Error method implementation for runnable examples. It writes the error message with "ERROR:" prefix.
func (*E) Errorf ¶
Errorf is a testing.TB Errorf method implementation for runnable examples. It writes the error message with "ERROR:" prefix.
func (*E) Fail ¶
func (e *E) Fail()
Fail is a testing.TB Fail method implementation for runnable examples.
func (*E) FailNow ¶
func (e *E) FailNow()
FailNow is a testing.TB FailNow method implementation for runnable examples.
func (*E) Helper ¶
func (e *E) Helper()
Helper is a testing.TB Helper method implementation for runnable examples.
func (*E) SkipNow ¶
func (e *E) SkipNow()
SkipNow is a testing.TB SkipNow method implementation for runnable examples.
type PrintingTBE ¶
type PrintingTBE interface { Helper() Errorf(format string, args ...interface{}) Error(args ...any) Log(args ...any) Logf(format string, args ...any) }
PrintingTBE is a subinterface of testing.TB that provides the printing methods of testing.TB (Log, Logf, Error, Errorf) and the Helper method.
type RequireTB ¶
type RequireTB interface { AssertTB FailNow() }
RequireTB is a subinterface of testing.TB that fulfills the needs of require package from testify library, but also includes the FailNow method. This package also provides an implementation of this interface, called testingx.E, that can be used in runnable examples.
type TB ¶
type TB interface { Cleanup(func()) Error(args ...any) Errorf(format string, args ...any) Fail() FailNow() Failed() bool Fatal(args ...any) Fatalf(format string, args ...any) Helper() Log(args ...any) Logf(format string, args ...any) Name() string Setenv(key, value string) Chdir(dir string) Skip(args ...any) SkipNow() Skipf(format string, args ...any) Skipped() bool TempDir() string Context() context.Context }
TB is a copy of testing.TB interface, that also allows for implementing it. This package also provides an implementation of this interface, called testingx.E, that can be used in runnable examples.
type TBE ¶
type TBE interface { PrintingTBE FailNow() }
TBE is a subinterface that gives reasonable minimum set of methods from testing.TB, that can be used in tests and runnable examples.