This testing guide describes how to execute tests and how to find out which percentage of codebase is covered by tests.
Find out which percentage of codebase is covered by tests and generate file containing a graphical representation of test converage.
-
Make sure that line
entrypoint: sleep infinity
indocker-compose.yaml
file is uncommented. -
Clean docker volumes.
docker-compose down -v
-
Compose and build the Docker container.
docker-compose up --build
-
List all containers and get container ID of the current container.
docker ps
-
Open shell inside the running container.
docker exec -ti <CONTAINER ID> /bin/bash
-
Get percentage of statements that is covered by tests.
go test -race -covermode=atomic -coverprofile=coverage.out
-
Generate a file containing a graphical summary of covered statements and get path to the file.
go tool cover -html=coverage.out
-
Exit the container's shell.
exit
-
Copy the
coverage.out
file from the container to your computer.docker cp <CONTAINER ID>:<PATH TO FILE> <PATH TO LOCATION WHERE FILE WILL BE SAVED>