Comments (2)
Thank you for the bug report! When I was added tests for a change to coverage support I recall there being problems with the testname
format when -coverprofile
is enabled.
The formatters take the Output
field from the events described in https://pkg.go.dev/cmd/test2json and attempt to display the correct ones. The bug seems to be that coverprofile adds extra Output
lines that aren't handled correctly.
It's also possible this output has changed in a more recent version of Go, and that may be why there are extra lines now.
The code for the testname
format is here:
Lines 141 to 184 in 3735b72
If you can share the go test -json
output, that should help fix the problem.
from gotestsum.
I use Go version 1.22.
$ go version
go version go1.22.1 linux/amd64
Below the output of go test -json
without and with -coverprofile
:
$ go test -json ./...
{"Time":"2024-03-26T09:09:49.992462224+01:00","Action":"start","Package":"example/hello"}
{"Time":"2024-03-26T09:09:49.992569598+01:00","Action":"start","Package":"example/hello/anotherpkg"}
{"Time":"2024-03-26T09:09:49.992599308+01:00","Action":"output","Package":"example/hello/anotherpkg","Output":"? \texample/hello/anotherpkg\t[no test files]\n"}
{"Time":"2024-03-26T09:09:49.992607825+01:00","Action":"skip","Package":"example/hello/anotherpkg","Elapsed":0}
{"Time":"2024-03-26T09:09:49.993343854+01:00","Action":"run","Package":"example/hello","Test":"TestHello"}
{"Time":"2024-03-26T09:09:49.993365569+01:00","Action":"output","Package":"example/hello","Test":"TestHello","Output":"=== RUN TestHello\n"}
{"Time":"2024-03-26T09:09:49.99339785+01:00","Action":"output","Package":"example/hello","Test":"TestHello","Output":"--- PASS: TestHello (0.00s)\n"}
{"Time":"2024-03-26T09:09:49.993404184+01:00","Action":"pass","Package":"example/hello","Test":"TestHello","Elapsed":0}
{"Time":"2024-03-26T09:09:49.993408811+01:00","Action":"output","Package":"example/hello","Output":"PASS\n"}
{"Time":"2024-03-26T09:09:49.993696835+01:00","Action":"output","Package":"example/hello","Output":"ok \texample/hello\t0.001s\n"}
{"Time":"2024-03-26T09:09:49.994080965+01:00","Action":"pass","Package":"example/hello","Elapsed":0.002}
{"Time":"2024-03-26T09:09:50.004938203+01:00","Action":"start","Package":"example/hello/apackage"}
{"Time":"2024-03-26T09:09:50.005625687+01:00","Action":"run","Package":"example/hello/apackage","Test":"TestFoo"}
{"Time":"2024-03-26T09:09:50.005637775+01:00","Action":"output","Package":"example/hello/apackage","Test":"TestFoo","Output":"=== RUN TestFoo\n"}
{"Time":"2024-03-26T09:09:50.005677401+01:00","Action":"output","Package":"example/hello/apackage","Test":"TestFoo","Output":"foo\n"}
{"Time":"2024-03-26T09:09:50.005688205+01:00","Action":"output","Package":"example/hello/apackage","Test":"TestFoo","Output":"--- PASS: TestFoo (0.00s)\n"}
{"Time":"2024-03-26T09:09:50.005696831+01:00","Action":"pass","Package":"example/hello/apackage","Test":"TestFoo","Elapsed":0}
{"Time":"2024-03-26T09:09:50.005706491+01:00","Action":"output","Package":"example/hello/apackage","Output":"PASS\n"}
{"Time":"2024-03-26T09:09:50.006033933+01:00","Action":"output","Package":"example/hello/apackage","Output":"ok \texample/hello/apackage\t0.001s\n"}
{"Time":"2024-03-26T09:09:50.006302826+01:00","Action":"pass","Package":"example/hello/apackage","Elapsed":0.001}
$ go test -json ./... -coverprofile=cover.txt
{"Time":"2024-03-26T09:09:54.45858177+01:00","Action":"start","Package":"example/hello"}
{"Time":"2024-03-26T09:09:54.458725526+01:00","Action":"start","Package":"example/hello/anotherpkg"}
{"Time":"2024-03-26T09:09:54.45879087+01:00","Action":"start","Package":"example/hello/apackage"}
{"Time":"2024-03-26T09:09:54.459795512+01:00","Action":"run","Package":"example/hello","Test":"TestHello"}
{"Time":"2024-03-26T09:09:54.459805312+01:00","Action":"output","Package":"example/hello","Test":"TestHello","Output":"=== RUN TestHello\n"}
{"Time":"2024-03-26T09:09:54.45983974+01:00","Action":"output","Package":"example/hello","Test":"TestHello","Output":"--- PASS: TestHello (0.00s)\n"}
{"Time":"2024-03-26T09:09:54.459844837+01:00","Action":"pass","Package":"example/hello","Test":"TestHello","Elapsed":0}
{"Time":"2024-03-26T09:09:54.459850483+01:00","Action":"output","Package":"example/hello","Output":"PASS\n"}
{"Time":"2024-03-26T09:09:54.459854333+01:00","Action":"output","Package":"example/hello","Output":"coverage: 0.0% of statements\n"}
{"Time":"2024-03-26T09:09:54.45986771+01:00","Action":"run","Package":"example/hello/apackage","Test":"TestFoo"}
{"Time":"2024-03-26T09:09:54.45987908+01:00","Action":"output","Package":"example/hello/apackage","Test":"TestFoo","Output":"=== RUN TestFoo\n"}
{"Time":"2024-03-26T09:09:54.459892145+01:00","Action":"output","Package":"example/hello/apackage","Test":"TestFoo","Output":"foo\n"}
{"Time":"2024-03-26T09:09:54.459898106+01:00","Action":"output","Package":"example/hello/apackage","Test":"TestFoo","Output":"--- PASS: TestFoo (0.00s)\n"}
{"Time":"2024-03-26T09:09:54.459900914+01:00","Action":"pass","Package":"example/hello/apackage","Test":"TestFoo","Elapsed":0}
{"Time":"2024-03-26T09:09:54.459903831+01:00","Action":"output","Package":"example/hello/apackage","Output":"PASS\n"}
{"Time":"2024-03-26T09:09:54.460030451+01:00","Action":"output","Package":"example/hello","Output":"ok \texample/hello\t0.001s\tcoverage: 0.0% of statements\n"}
{"Time":"2024-03-26T09:09:54.460038761+01:00","Action":"pass","Package":"example/hello","Elapsed":0.001}
{"Time":"2024-03-26T09:09:54.460176944+01:00","Action":"output","Package":"example/hello/apackage","Output":"coverage: 100.0% of statements\n"}
{"Time":"2024-03-26T09:09:54.460359785+01:00","Action":"output","Package":"example/hello/apackage","Output":"ok \texample/hello/apackage\t0.001s\tcoverage: 100.0% of statements\n"}
{"Time":"2024-03-26T09:09:54.46036672+01:00","Action":"pass","Package":"example/hello/apackage","Elapsed":0.002}
{"Time":"2024-03-26T09:09:54.465235329+01:00","Action":"output","Package":"example/hello/anotherpkg","Output":"\texample/hello/anotherpkg\t\tcoverage: 0.0% of statements\n"}
{"Time":"2024-03-26T09:09:54.466021445+01:00","Action":"pass","Package":"example/hello/anotherpkg","Elapsed":0.007}
from gotestsum.
Related Issues (20)
- . HOT 1
- Support running tests using RR HOT 3
- Support(): When I use gotestsum, some unexpected message output HOT 1
- watcher: warning on invalid symlinks HOT 2
- error when go install v1.11.0 HOT 4
- gotestsum slow in dind container HOT 2
- junitxml: include full output in system-out field HOT 7
- Duplicated `go test` arguments on rerun, causing `package is not in std` HOT 1
- `--junitfile` XML report contains all test runs if using `--rerun-fails` HOT 2
- Need Help with rerun-fails HOT 6
- Support Markdown formatted output. HOT 3
- Order of packages when using pkgname HOT 2
- Support for Fuzzy Testing using testing.F HOT 1
- `--rerun-fails` doesn't work when `--packages` specifies a source file HOT 1
- why does the testname format does not support icons? HOT 1
- Test cases passed but gotestsum print out Failed in summary HOT 7
- Warn on foo.go~ when using --watch HOT 2
- gotestsum support to run multiple tests using fully qualified name of tests HOT 3
- Latest dependabot update raises module requirement to Go 1.19 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotestsum.