go2xunit icon indicating copy to clipboard operation
go2xunit copied to clipboard

TestMain failures aren't translated to error codes

Open jwilner opened this issue 6 years ago • 1 comments

When a package uses a TestMain that exits with an error before running tests, go2xunit suppresses the error.

~/code/sample ➭ cat sample_test.go
package main

import (
    "os"
    "testing"
)

func TestMain(t *testing.M) {
    os.Exit(1)
}
~/code/sample ➭ go test -v ./...
exit status 1
FAIL	_/Users/jwilner/code/sample	0.005s
~/code/sample ➭ go test -v ./... | go2xunit -fail
<?xml version="1.0" encoding="UTF-8"?>

  <testsuite name="_/Users/jwilner/code/sample" tests="0" errors="0" failures="0" skip="0">
  </testsuite>
~/code/sample ➭ echo $?
0

jwilner avatar Mar 28 '19 19:03 jwilner

Thanks for reporting. I'll have a look this weekend.

tebeka avatar Mar 31 '19 16:03 tebeka