Skip to content

Commit 5684af2

Browse files
authored
Merge pull request #779 from cpanato/GH-692
makefile: Add a make target to generate test coverage report
2 parents 3b2f7fd + ea8ae55 commit 5684af2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ bin
1111

1212
# Output of the go coverage tool, specifically when used with LiteIDE
1313
*.out
14+
coverage.*
1415

1516
# Ansible
1617
*.retry

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,21 @@ help: ## Display this help
135135
.PHONY: test
136136
test: generate lint go-test ## Run generate lint and tests
137137

138-
go-test: export TEST_ASSET_KUBECTL = $(KUBECTL)
139-
go-test: export TEST_ASSET_KUBE_APISERVER = $(KUBE_APISERVER)
140-
go-test: export TEST_ASSET_ETCD = $(ETCD)
138+
envs-test:
139+
export TEST_ASSET_KUBECTL = $(KUBECTL)
140+
export TEST_ASSET_KUBE_APISERVER = $(KUBE_APISERVER)
141+
export TEST_ASSET_ETCD = $(ETCD)
141142

142143
.PHONY: go-test
143-
go-test: $(KUBECTL) $(KUBE_APISERVER) $(ETCD) ## Run go tests
144+
go-test: envs-test $(KUBECTL) $(KUBE_APISERVER) $(ETCD) ## Run go tests
145+
echo $(TEST_ASSET_KUBECTL)
144146
go test ./...
145147

148+
.PHONY: test-cover
149+
test-cover: envs-test $(KUBECTL) $(KUBE_APISERVER) $(ETCD) ## Run tests with code coverage and code generate reports
150+
go test -v -coverprofile=coverage.out ./...
151+
go tool cover -func=coverage.out -o coverage.txt
152+
go tool cover -html=coverage.out -o coverage.html
146153

147154
.PHONY: test-integration
148155
test-integration: ## Run integration tests

0 commit comments

Comments
 (0)