panic in TearDownTest obscures original test panic
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gocheck |
New
|
Undecided
|
Unassigned |
Bug Description
I just had a test where something in the test was panicking
and that had the consequence of causing TearDownTest
to panic.
Unfortunately the original panic message or stack trace is never printed
in this case, making the problem hard to diagnose.
Here is a standalone test file that demonstrates the issue:
package test_test
import (
gc "launchpad.
"testing"
)
func TestPackage(t *testing.T) {
gc.TestingT(t)
}
var _ = gc.Suite(suite{})
type suite struct{}
func (suite) TearDownTest(c *gc.C) {
c.Logf("tear down test")
panic("panic in TearDownTest")
}
func (suite) TestFoo(c *gc.C) {
c.Logf("testing Foo")
panic("panic in TestFoo")
}
This produces this output:
------
PANIC: tst_test.go:16: suite.TearDownTest
tear down test
... Panic: panic in TearDownTest (PC=0x413776)
/home/
in panic
tst_test.go:18
in suite.TearDownTest
tst_test.go:1
in suite.TearDownT
/home/
in call16
------
PANIC: tst_test.go:21: suite.TestFoo
testing Foo
... Panic: Fixture has panicked (see related PANIC)
OOPS: 0 passed, 1 FIXTURE-PANICKED, 1 MISSED
--- FAIL: TestPackage (0.00 seconds)
FAIL
FAIL command-
go: exit 1