Skip to content

Commit

Permalink
add test coverage reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
pirtleshell committed Sep 21, 2023
1 parent e04a2c2 commit b7dbeac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ kava-proxy-service

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# coverage report converted to HTML
cover.html

# Dependency directories (remove the comment below to include it)
# vendor/
Expand Down
8 changes: 8 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ The e2e tests won't pass if the proxy service and it's dependencies aren't fully
make ready e2e-test
```

## Test Coverage Report

The test commands `make test`, `make unit-test`, and `make e2e-test` generate a `cover.out` raw test coverage report. The coverage can be converted into a user-friendly webpage:

```bash
make show-coverage
```

### Running specific tests only

Often during iterative development you want to run only a specific test (or group of tests), the `it` target will allow you to do just that:
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,28 @@ publish: lint
.PHONY: unit-test
# run all unit tests
unit-test:
go test -count=1 -v -cover --race ./... -run "^TestUnitTest*"
go test -count=1 -v -cover -coverprofile cover.out --race ./... -run "^TestUnitTest*"

.PHONY: e2e-test
# run tests that execute against a local or remote instance of the API
e2e-test:
go test -count=1 -v -cover --race ./... -run "^TestE2ETest*"
go test -count=1 -v -cover -coverprofile cover.out --race ./... -run "^TestE2ETest*"

.PHONY: it
# run any test matching the provided pattern, can pass a regex or a string
# of the exact test to run
it : lint
go test -count=1 -v -cover --race ./... -run=".*${p}.*"
go test -count=1 -v -cover -coverprofile cover.out --race ./... -run=".*${p}.*"

.PHONY: show-coverage
# convert test coverage report to html & open in browser
show-coverage:
go tool cover -html cover.out -o cover.html && open cover.html

.PHONY: test
# run all tests
test: unit-test e2e-test
test:
go test -count=1 -v -cover -coverprofile cover.out --race ./...

.PHONY: up
# start dockerized versions of the service and it's dependencies
Expand Down

0 comments on commit b7dbeac

Please sign in to comment.