Running Unit Tests for Multi-git
In this lesson, you will learn how to run the unit tests we created in the previous lesson using either go test or Ginkgo. We will also check the test coverage and run focused tests, which is very useful during development.
We'll cover the following...
Running Ginkgo tests
As you recall, Ginkgo tests are actually standard Go tests. We can run them either with go test
or using the Ginkgo CLI. Let’s try both.
Running Ginkgo tests with “go test”
This is exactly the same as running non-Ginkgo tests. Just type go test
to run all the Ginkgo tests.
The go test
command has several other command-line arguments that can be useful. Check out the full list here: https://golang.org/cmd/go/#hdr-Testing_flags
However, when running Ginkgo tests, I recommend using the Ginkgo command itself.
Running Ginkgo tests with Ginkgo
First, make sure that ginkgo is installed. If it’s not, follow the instructions here: https://onsi.github.io/ginkgo/#getting-ginkgo
As you can see, the context and the test name are displayed for each test.
Checking test coverage
We can check the test coverage with Ginkgo as well using the ginkgo -cover
command.
Okay. We have 70.6% coverage, ...