MCPcopy Create free account
hub / github.com/stretchr/testify / Error

Function Error

assert/assertions.go:1598–1607  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

1596// assert.Equal(t, expectedError, err)
1597// }
1598func Error(t TestingT, err error, msgAndArgs ...interface{}) bool {
1599 if err == nil {
1600 if h, ok := t.(tHelper); ok {
1601 h.Helper()
1602 }
1603 return Fail(t, "An error is expected but got nil.", msgAndArgs...)
1604 }
1605
1606 return true
1607}
1608
1609// EqualError asserts that a function returned an error (i.e. not `nil`)
1610// 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