MCPcopy
hub / github.com/stretchr/testify / Error

Function Error

assert/assertions.go:1648–1657  ·  view source on GitHub ↗

Error asserts that a function returned an error (i.e. not `nil`). actualObj, err := SomeFunction() assert.Error(t, err)

(t TestingT, err error, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1646// actualObj, err := SomeFunction()
1647// assert.Error(t, err)
1648func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
1649 if err == nil {
1650 if h, ok := t.(tHelper); ok {
1651 h.Helper()
1652 }
1653 return Fail(t, "An error is expected but got nil.", msgAndArgs...)
1654 }
1655
1656 return true
1657}
1658
1659// EqualError asserts that a function returned an error (i.e. not `nil`)
1660// and that it is equal to the provided error.

Callers 6

ErrorFunction · 0.92
ErrorfFunction · 0.70
TestErrorFunction · 0.70
EqualErrorFunction · 0.70
ErrorContainsFunction · 0.70
ErrorMethod · 0.70

Calls 2

FailFunction · 0.70
HelperMethod · 0.65

Tested by 1

TestErrorFunction · 0.56