-
Notifications
You must be signed in to change notification settings - Fork 668
replace homegrown testing library with something off-the-shelf #358
Comments
Advantage of testify is that it is a drop-in replacement for our custom testing package. Have asked @peterbourgon if he has any opinion... |
Per f2f discussion with @rade, need to see if gocheck provides better failure stacktraces. testify just gives line-number of assertion, which makes refactoring assertions harder. |
I fully endorse the Go philosophy of testing as summarized in the FAQ, quote,
I suppose testify is preferable to gocheck, and either is preferable to goconvey. But (brutal honesty ahead) I don't see much value in any of these functions and would prefer to just inline them in the relevant tests, eliminating the package altogether. |
Thereby turning every assertion in a three-line |
Sure. For example. Neither newlines nor vertical screen space are limited resources :) |
That is gross, but I guess we'll just have to agree to disagree. |
After trying them: unlike testify, gocheck does give stacktraces of failures |
But, does come with a lot of other baggage. :( |
Curious: you can generate a stacktrace on demand with debug.PrintStack; what does integration with a testing package get you? |
It tells us which test failed, in the case where the assertion is not at the top level. e.g. func TestSomething(t *testing.T) {
helper(t)
}
func TestSomethingElse(t *testing.T) {
helper(t)
}
func helper(t *testing.T) {
t.Fatal("failure!")
} Edit: and also the line-number within the test which failed. |
So, the options so far seem to be:
Of those, I prefer 3. By inlining everything, I worry we'll end up re-inventing stuff all over the place, and end up back where we started. |
@paulbellamy what about wrapping Fatals with something that invokes stack.Caller? |
@peterbourgon Do you mean like this? Or something else in mind? https://github.com/weaveworks/weave/blob/master/testing/util.go#L133 |
@paulbellamy Ah, I see. Yes. I'd rename that to e.g. |
@peterbourgon Right. Given that, I'd also be ok with inlining checks, and using the "XxxWithStack" variants in any helpers. |
Our testing util library is growing. It's still quite small, but at some point we should probably bite the bullet and pull in something like gocheck or testify.
The text was updated successfully, but these errors were encountered: