From 84ae6ac138c8f39f48678fec25158bf0cf048664 Mon Sep 17 00:00:00 2001 From: Thomas <94226683+ThomasWall03@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:34:32 +0100 Subject: [PATCH] Add make target for executing unit tests with test coverage (#396) * Add test-cov make target * Update .gitignore Co-authored-by: Marc Vornetran * Exclude /pkg/client from coverprofile * update test coverage script to exclude /pkg/client and remove test-cover Script --------- Co-authored-by: Marc Vornetran --- .gitignore | 3 +++ Makefile | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 9e218b05..f712be44 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,8 @@ tmp/ .vscode/ .kubeconfig-kind-integration +*.coverprofile +*.html + # gosec gosec-report.sarif diff --git a/Makefile b/Makefile index 364dbd07..fdfe4fc2 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,10 @@ test: $(GINKGO) test-integration: $(REPORT_COLLECTOR) $(SETUP_ENVTEST) @bash $(GARDENER_HACK_DIR)/test-integration.sh ./test/integration/... +.PHONY: test-cov +test-cov: + @bash $(GARDENER_HACK_DIR)/test-cover.sh $(shell go list ./pkg/... | grep -v /pkg/client) ./cmd/... + .PHONY: generate generate: $(VGOPATH) $(CONTROLLER_GEN) @GARDENER_HACK_DIR=$(GARDENER_HACK_DIR) VGOPATH=$(VGOPATH) REPO_ROOT=$(REPO_ROOT) ./hack/generate-code