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

Method ErrorContains

require/require_forward.go:278–283  ·  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

276// actualObj, err := SomeFunction()
277// a.ErrorContains(err, expectedErrorSubString)
278func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) {
279 if h, ok := a.t.(tHelper); ok {
280 h.Helper()
281 }
282 ErrorContains(a.t, theError, contains, msgAndArgs...)
283}
284
285// ErrorContainsf asserts that a function returned an error (i.e. not `nil`)
286// 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