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

Method ErrorContains

assert/assertion_forward.go:277–282  ·  view source on GitHub ↗

ErrorContains asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring. actualObj, err := SomeFunction() a.ErrorContains(err, expectedErrorSubString)

(theError error, contains string, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

275// actualObj, err := SomeFunction()
276// a.ErrorContains(err, expectedErrorSubString)
277func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool {
278 if h, ok := a.t.(tHelper); ok {
279 h.Helper()
280 }
281 return ErrorContains(a.t, theError, contains, msgAndArgs...)
282}
283
284// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
285// and that the error contains the specified substring.

Callers 1

TestErrorContainsWrapperFunction · 0.45

Calls 2

ErrorContainsFunction · 0.70
HelperMethod · 0.65

Tested by 1

TestErrorContainsWrapperFunction · 0.36