Skip to content

Commit e115a0e

Browse files
authored
chore: add make option to create test coverage reports (#741)
1 parent a2c25be commit e115a0e

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ go.work.sum
3434

3535
# Unit test files
3636
stackit/internal/services/iaas/test-512k.img
37+
38+
# Test coverage reports
39+
coverage.out
40+
coverage.html

CONTRIBUTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ These commands can be executed from the project root:
2626
- `make lint`: lint the code and examples
2727
- `make generate-docs`: generate terraform documentation
2828
- `make test`: run unit tests
29+
- `make coverage`: create unit test coverage report (output file: `stackit/coverage.html`)
2930
- `make test-acceptance-tf`: run acceptance tests
3031

3132
### Repository structure

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ test:
3737
@echo "Running tests for the terraform provider"
3838
@cd $(ROOT_DIR)/stackit && go test ./... -count=1 && cd $(ROOT_DIR)
3939

40+
# Test coverage
41+
coverage:
42+
@echo ">> Creating test coverage report for the terraform provider"
43+
@cd $(ROOT_DIR)/stackit && (go test ./... -count=1 -coverprofile=coverage.out || true) && cd $(ROOT_DIR)
44+
@cd $(ROOT_DIR)/stackit && go tool cover -html=coverage.out -o coverage.html && cd $(ROOT_DIR)
45+
4046
test-acceptance-tf:
4147
@if [ -z $(TF_ACC_PROJECT_ID) ]; then echo "Input TF_ACC_PROJECT_ID missing"; exit 1; fi
4248
@if [ -z $(TF_ACC_ORGANIZATION_ID) ]; then echo "Input TF_ACC_ORGANIZATION_ID missing"; exit 1; fi

0 commit comments

Comments
 (0)