Skip to content

Commit f389b5a

Browse files
committed
Add make tasks for running tests and generating coverage reports
1 parent b1e2e0b commit f389b5a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ compile: ensure-out-dir ## compiles kube-tmuxp for this platform
2727
compile-linux: ensure-out-dir ## compiles kube-tmuxp for linux
2828
GOOS=linux GOARCH=amd64 $(GOBIN) build -o $(APP_EXECUTABLE) ./main.go
2929

30-
fmt: # format go code
30+
fmt: ## format go code
3131
$(GOBIN) fmt $(SRC_PACKAGES)
3232

33-
vet: # examine go code for suspicious constructs
33+
vet: ## examine go code for suspicious constructs
3434
$(GOBIN) vet $(SRC_PACKAGES)
3535

3636
setup: ## setup environment
@@ -42,3 +42,13 @@ build: fmt vet compile ## build the application
4242

4343
mocks: ## generate mocks for testing
4444
./scripts/mocks
45+
46+
tests: ## run all tests
47+
$(GOBIN) test $(SRC_PACKAGES) -p=1 -coverprofile ./out/coverage -v
48+
49+
tests-cover-html: ensure-out-dir ## run all tests and generates coverage report in html
50+
@echo "mode: count" > out/coverage-all.out
51+
$(foreach pkg, $(SRC_PACKAGES),\
52+
$(GOBIN) test -coverprofile=out/coverage.out -covermode=count $(pkg);\
53+
tail -n +2 out/coverage.out >> out/coverage-all.out;)
54+
$(GOBIN) tool cover -html=out/coverage-all.out -o out/coverage.html

0 commit comments

Comments
 (0)