golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.29k stars 610 forks source link

The package “github.com/golang/mock/sample/mock_user” is a mock file, This package shouldn't be calculated coverage. #560

Closed liufangwai closed 3 years ago

liufangwai commented 3 years ago

Actual behavior A clear and concise description of what the bug is. The package “github.com/golang/mock/sample/mock_user” is a mock file, This package shouldn't be calculated coverage. When I run "go test -coverpkg=./... github.com/golang/mock/sample --coverprofile=cover.out", this package will be calculated coverage and as uncovered

Expected behavior A clear and concise description of what you expected to happen. The package “github.com/golang/mock/sample/mock_user” is a mock file, This package shouldn't be calculated coverage.

To Reproduce Steps to reproduce the behavior 1, Run this command: go test -coverpkg=./... github.com/golang/mock/sample --coverprofile=cover.out 2, cat cover.out, the package "github.com/golang/mock/sample/mock_user” will be calculated coverage and as uncovered

Additional Information

a little more: When this file " github.com/golang/mock/sample/mock_user/mock_user.go " was renamed to " github.com/golang/mock/sample/mock_user/mock_user_test.go " , this file will be identified as test file , and this problem will be sovled。 Triage Notes for the Maintainers

codyoss commented 3 years ago

Hey, although I too generate my mocks as test files I do not think everyone does and it is valid to generate them as a non-test. I will take a look at this example when I have time though. I am not worried that this counts against coverage though as it is just a sample.