Reputation: 607
TL;DR: Is there any known hack to capture and/or print additional context when a Golang test fails? (using standard library testing
)
Example:
func TestSomething(t *testing.T) {
...
...
if ... {
t.Fatalf("Something went wrong!")
}
I would like to attach some generic function to be invoked before the test returns, e.g. debug.PrintStack()
I am working on a large codebase with hundreds of tests.
defer
)go test
logic...debug.PrintStack()
-- I want to notify some other system of the test failure)I can see from testing
documentation and code that this is not supported.
However I also know if one is determined enough, this is possible, and I am hoping someone can point to some clever hack I can take inspiration from.
Upvotes: 0
Views: 46