Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage not showing correct value #2

Open
jgheewala opened this issue Sep 6, 2024 · 3 comments
Open

Coverage not showing correct value #2

jgheewala opened this issue Sep 6, 2024 · 3 comments

Comments

@jgheewala
Copy link

Hi,

I have a mock package with 15 mock_*_test.go files. In one of the test file I add following

func TestMain(m *testing.M) { coverage.Run(m, 90) }

However when I am running the test it shows FAIL even when coverage is at 94.2%

`❯ go test -cover $(go list ./... | grep pkg/mock)
PASS
coverage: 94.2% of statements

FAIL Coverage threshold not met 90.0 >= 32.2 for tracing/pkg/mock

FAIL tracing/pkg/mock 0.399s
FAIL`

@gkampitakis
Copy link
Owner

I am suspecting it has to do something with golang/go#65570, can you try with

GOEXPERIMENT=nocoverageredesign

Also I am not sure how accurate this library might be in general. It uses testing.Coverage which states on the docs

// It is not a replacement for the reports generated by 'go test -cover' and
// 'go tool cover'.

@jgheewala
Copy link
Author

adding GOEXPERIMENT=nocoverageredesign worked. For me the problem is we have taken task to increase the unit test coverage across all our services and hence we would be doing one package at a time.. It will be too much of work for writing a makefile which uses go tool cover

@gkampitakis
Copy link
Owner

Oh I see. Hopefully then this package will help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants