tebeka / go2xunit

Convert "go test" output to xunit compatible (used in Jenkins/Hudson)
MIT License
162 stars 46 forks source link

TestMain failures aren't translated to error codes #66

Open jwilner opened 5 years ago

jwilner commented 5 years ago

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
tebeka commented 5 years ago

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