File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,3 +34,7 @@ go.work.sum
3434
3535# Unit test files
3636stackit /internal /services /iaas /test-512k.img
37+
38+ # Test coverage reports
39+ coverage.out
40+ coverage.html
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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+
4046test-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
You can’t perform that action at this time.
0 commit comments