gotestyourself / gotestyourself/gotestsum

gotestsum reports TestMain when it fails but not when it passes

Open
#220 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.7k
Forks
171
PR merge metrics
No merged PRs in 30d

Description

I have a test package which has a `TestMain` function, and I've tried to use `gotestsum --junitfile report.xml` to run it. However, I've observed the behavior for the `TestMain` JUnit result is different when it passes and fails.

1. When the `TestMain` fails, the `report.xml` file has a `TestMain` test case failure.
```
func TestMain(m *testing.M) {
log.Fatal("fatal")
os.Exit(m.Run())
}
```

2. When the `TestMain` passes, the `report.xml` file does not have a `TestMain` test case pass.
```
func TestMain(m *testing.M) {
os.Exit(m.Run())
}
```

It'll make more sense to always have `TestMain` as one test case in the JUnit result, regardless whether it passes or not.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with the two TestMain examples and compare the generated report.xml files. Trace the JUnit result generation path for TestMain, then verify that a passing TestMain produces a test case as well as a failing one.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.