Closed ghostsquad closed 6 years ago
Can you provide an example of the code that would have produced this failure message?
Also, how would you achieve passing the optional string?
The code is nothing more than
type Foo struct {}
type Bar struct {
Blah string
}
this.So(Foo{}, should.Equal, Bar{})
An example of usage might be an alternative interface
this.SoBecause(Foo{}.Active, should.BeFalse, "because we don't work with old clients")
# or
this.SoBecause(Baz.Foo, should.Equal, Bar{}, "because Foo is the new client")
Ok, I see. I don't see us adding that kind of feature to gunit. Usually we extract nicely-named methods to document the purpose of a given assertion.
func (this *MyFixture) assertFooIsTheNewClient() {
this.So(this.Baz.Foo, should.Equal, Bar{})
}
Have you tried GoConvey? It uses a more descriptive style that you might appreciate.
https://smartystreets.com/blog/2018/03/history-of-go-testing
Also, when comparing anything but primitive values, I often recommend using ShouldResemble
.
This is more information that you'd normally get, but it still requires a bit of research to figure out why the assertion failed.
It would be really nice to be able to provide my own
why it failed
message.