td.T
Constructing *td.T
func NewT(t testing.TB, config ...ContextConfig) *Tfunc Assert(t testing.TB, config ...ContextConfig) *Tfunc Require(t testing.TB, config ...ContextConfig) *Tfunc AssertRequire(t testing.TB, config ...ContextConfig) (assert, require *T)
Configuring *td.T
func (t *T) BeLax(enable ...bool) *Tfunc (t *T) FailureIsFatal(enable ...bool) *Tfunc (t *T) IgnoreUnexported(types ...any) *Tfunc (t *T) RootName(rootName string) *Tfunc (t *T) UseEqual(types ...any) *T
Main methods of *td.T
func (t *T) Cmp(got, expected any, args ...any) boolfunc (t *T) CmpError(got error, args ...any) boolfunc (t *T) CmpLax(got, expected any, args ...any) bool(in fact the shortcut ofLaxoperator)func (t *T) CmpNoError(got error, args ...any) boolfunc (t *T) CmpNotPanic(fn func(), args ...any) boolfunc (t *T) CmpPanic(fn func(), expected any, args ...any) boolfunc (t *T) False(got any, args ...any) boolfunc (t *T) Not(got, notExpected any, args ...any) bool(in fact the shortcut ofNotoperator)func (t *T) Run(name string, f func(t *T)) boolfunc (t *T) RunAssertRequire(name string, f func(assert, require *T)) boolfunc (t *T) True(got any, args ...any) bool
CmpDeeply()
method is now replaced by
Cmp(),
but it is still available for backward compatibility purpose.
Anchoring methods of *td.T
func (t *T) AT[X any](operator TestDeep) Xfunc (t *T) AnchorT[X any](operator TestDeep) Xfunc (t *T) AnchorsPersistTemporarily() func()func (t *T) DoAnchorsPersist() boolfunc (t *T) ResetAnchors()func (t *T) SetAnchorsPersist(persist bool)
Using generics but before go1.27, one can also use:
Before generics are available in go1.18, anchoring can be achieved using:
func (t *T) A(operator TestDeep, model ...any) anyfunc (t *T) Anchor(operator TestDeep, model ...any) any
Shortcut methods of *td.T
For each of these methods, it is always a shortcut on
T.Cmp() and
the correponding Testdeep operator:
Excluding Lax operator for which the
shortcut method stays CmpLax.
Each shortcut method is described in the corresponding operator page. See operators list.