-
Notifications
You must be signed in to change notification settings - Fork 23
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
Ignore test coverage for specified files #79
Comments
I think the best we can do is exclude packages. Is this what you're looking for? Although at this point you're better off using the native Go tooling to target specific tests. Otherwise you'd be running tests and then excluding them. Example:
And with an
|
That's not exactly what I meant. Let me explain. Golang doesn't allow to ignore some certain files or folders by default. For example I'd like to ignore some auto-generated files, or or some test utils, etc... One of the ways it can be done is to check the cover.out and grep -v the files/folders to ignore. Let me show you an example of a Makefile: IGNORE_COVERAGE_FOR=-e .*_gen.go -e backend-server.go -e backend-types.go -e internal -e test_helpers.go -e .*test
test-all:
@echo -e "$(OK_COLOR)==> Running tests$(NO_COLOR)"
set -euo pipefail && go test -tags="integration" -v -race -count=1 -timeout=180s -cover -covermode atomic -coverprofile=coverage.tmp -coverpkg=./... ./... | tee junit.out
@set -euo pipefail && cat coverage.tmp | grep -v $(IGNORE_COVERAGE_FOR) > coverage.out && rm coverage.tmp
test-pretty: ## run unit and integration tests with prety console output
@echo -e "$(OK_COLOR)==> Running tests$(NO_COLOR)"
@set -euo pipefail && go test -json -tags=integration -v -race -count=1 -timeout=120s -cover -covermode atomic ./... | tparse In this example UPD: I don't really want to ignore the whole package, but some files inside. |
At the moment
tparse
shows a nice table withcover
column, which is really cool. It would be even better if it was possible to specify an exclusion list for files and/or directories to ignore.The text was updated successfully, but these errors were encountered: