I am able to force the throw of a Panic statement, but no matter what I try I am unable to test it.
Test
func TestPanicStatement(t *testing.T) {
expected := "error"
actual := function("/file/does/not/exist.xml")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
}
Main
if err != nil {
panic(err)
}
Outcome
--- FAIL: TestPanicStatement (0.00s)
panic: EOF [recovered]
panic: EOF
goroutine 8 [running]: