Documentation
¶
Index ¶
- Constants
- func Diff(a any, b any) string
- func Dump(v any) string
- func Fail(t *testing.T, reason string, got any, expect ...any)
- func FailNow(t *testing.T, reason string, got any, expect ...any)
- func Fatal(t *testing.T, reason string, got any, expect ...any)
- type Witness
- func Actual(v any) *Witness
- func Debug(label string, info ...any) *Witness
- func Expect(v any) *Witness
- func Got(v any) *Witness
- func Message(label string, msg string) *Witness
- func Name(n string) *Witness
- func Namef(format string, a ...any) *Witness
- func New(showFlag ...bool) *Witness
- func Want(v any) *Witness
- func (w *Witness) Actual(v any) *Witness
- func (w *Witness) Debug(label string, info ...any) *Witness
- func (w *Witness) Expect(v any) *Witness
- func (w *Witness) Fail(t *testing.T, reason string, traceFilterFunc ...func(filepath string) bool)
- func (w *Witness) FailNow(t *testing.T, reason string, traceFilterFunc ...func(filepath string) bool)
- func (w *Witness) Fatal(t *testing.T, reason string)
- func (w *Witness) Got(v any) *Witness
- func (w *Witness) Message(label string, msg string) *Witness
- func (w *Witness) Name(n string) *Witness
- func (w *Witness) Namef(format string, a ...any) *Witness
- func (w *Witness) ShowAll() *Witness
- func (w *Witness) ShowDiff() *Witness
- func (w *Witness) ShowRaw() *Witness
- func (w *Witness) Want(v any) *Witness
Constants ¶
const ShowDiff, ShowRaw, NotShowDiff, NotShowRaw = true, true, false, false
You can write "witness.New(witness.ShowDiff, witness.NotShowRaw)" instead of raw boolean
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff is to get a diff string of 2 objects for debugging in test Two args should be same type. Otherwise, diff string will be a blank string.
func Fail ¶
Fail is shortcut method. These are same expression.
witness.Got(got).Fail(t, reason) witness.Fail(t, reason, got)
Fail with 2 values cases are below
witness.Got(got).Expect(expect).Fail(t, reason) witness.Fail(t, reason, got, expect)
Types ¶
type Witness ¶
type Witness struct {
// contains filtered or unexported fields
}
Witness is a context of the fail report
func Actual ¶ added in v0.0.15
Set a value you actually got. The `Actual` method is an alias of the `Got` method.
func New ¶
You don't need to call `New`. You can call `Got` or `Expect` directly without calling `New` like below.
witness.Got("abc").Fail(t, "somehow")
You should call `New` when you need to set options for several reports in order to avoid calling `ShowDiff` or `ShowRaw` for each report.
w := witness.New(witness.ShowDiff, witness.ShowRaw) w.Got(123).Fail(t, "Not expected") w.Got("c").Fail(t, "Expected d")
func Want ¶ added in v0.0.15
Set a value you want. The `Want` method is an alias of the `Expect` method.
func (*Witness) Actual ¶ added in v0.0.15
Set a value you actually got. The `Actual` method is an alias of the `Got` method.
func (*Witness) FailNow ¶
func (w *Witness) FailNow(t *testing.T, reason string, traceFilterFunc ...func(filepath string) bool)
Do fail with report and stop running test right now
func (*Witness) Fatal ¶ added in v0.0.15
Do fail with report and stop running test right now. The `Fatal` method is an alias of the `FailNow` method.