mirror of https://github.com/stretchr/testify.git
Test verbose Contains Fail message
If asserting an error contained in a string, includeElement will fail but Contains will confusingly print both values as strings, which can look like a testify problem instead of an assertion failure.pull/579/head
parent
c12dcedf28
commit
cb23521296
|
@ -592,6 +592,18 @@ func TestContains(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestContainsFailMessage(t *testing.T) {
|
||||
|
||||
mockT := new(mockTestingT)
|
||||
|
||||
Contains(mockT, "Hello World", errors.New("Hello"))
|
||||
expectedFail := "\"Hello World\" does not contain &errors.errorString{s:\"Hello\"}"
|
||||
actualFail := mockT.errorString()
|
||||
if !strings.Contains(actualFail, expectedFail) {
|
||||
t.Errorf("Contains failure should include %q but was %q", expectedFail, actualFail)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotContains(t *testing.T) {
|
||||
|
||||
mockT := new(testing.T)
|
||||
|
|
Loading…
Reference in New Issue