mirror of https://github.com/stretchr/testify.git
fail: add test name for logged output
In case of a test failure, the test name will be logged to the output with makes debugging easier, specially in case of table driven tests.pull/465/head^2
parent
6e494f9834
commit
b3dfaa9086
|
@ -231,6 +231,13 @@ func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool {
|
|||
{"Error", failureMessage},
|
||||
}
|
||||
|
||||
// Add test name if the Go version supports it
|
||||
if n, ok := t.(interface {
|
||||
Name() string
|
||||
}); ok {
|
||||
content = append(content, labeledContent{"Test", n.Name()})
|
||||
}
|
||||
|
||||
message := messageFromMsgAndArgs(msgAndArgs...)
|
||||
if len(message) > 0 {
|
||||
content = append(content, labeledContent{"Messages", message})
|
||||
|
|
Loading…
Reference in New Issue