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

Function Error

require/require.go:286–294  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

284// require.Equal(t, expectedError, err)
285// }
286func Error(t TestingT, err error, msgAndArgs ...interface{}) {
287 if h, ok := t.(tHelper); ok {
288 h.Helper()
289 }
290 if assert.Error(t, err, msgAndArgs...) {
291 return
292 }
293 t.FailNow()
294}
295
296// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
297// This is a wrapper for errors.As.

Callers 2

ErrorMethod · 0.70
TestErrorFunction · 0.70

Calls 3

ErrorFunction · 0.92
HelperMethod · 0.65
FailNowMethod · 0.65

Tested by 1

TestErrorFunction · 0.56