gotestsum icon indicating copy to clipboard operation
gotestsum copied to clipboard

fix(junit): Correctly identify panicking test in JUnit report

Open vtsachev opened this issue 8 months ago • 1 comments

When a test panics, the JUnit XML report previously marked all tests in the package as failed. This change introduces tracking for the specific test ID that first emits panic output. The JUnit reporter now uses this ID to mark the panicking test with instead of the generic "Failed", while allowing other tests in the package to retain their correct status. This addresses the issue where a single panic would incorrectly attribute failure to the entire package in the report.

vtsachev avatar Apr 16 '25 23:04 vtsachev

Thanks for the PR!

Since all the tests in a package run in the same process, I don't think it's safe to assume anything about which test caused the panic. From what I remember the go test runner itself is not all that reliable about reporting where the panic came from. Plenty of times it will parse the panic as not being part of any test, but only part of the package.

Is the current behaviour causing problems? Do you see panics that often? Maybe there's a way the source of the panics can be fixed so that tests fail instead of panic?

dnephin avatar May 06 '25 03:05 dnephin