Test succeeded when a panic occurs Follow
Today I had the following issue: I have written a test where I tried to access an element in a slice which is not available.
In the log I received the following error message: panic: runtime error: index out of range [10] with length 2
But: The test in the GoLand IDEA itself succeeded!?
By executing the test in the terminal I got the following output:
panic: runtime error: index out of range [10] with length 2 [recovered]
panic: runtime error: index out of range [10] with length 2
goroutine 55 [running]:
testing.tRunner.func1.1(0xaff200, 0xc0002bbba0)
/usr/local/go-1.14/src/testing/testing.go:941 +0x3d0
testing.tRunner.func1(0xc00aac6a20)
/usr/local/go-1.14/src/testing/testing.go:944 +0x3f9
panic(0xaff200, 0xc0002bbba0)
...
FAIL
Go version used:
go version go1.14 linux/amd64
I can reproduce the failure by writing a test which only panics:
func Test_Foo(t *testing.T) {
panic("foo")
}
Please sign in to leave a comment.
Hi,
The related issues: https://youtrack.jetbrains.com/issue/GO-8916 and https://youtrack.jetbrains.com/issue/GO-8876