...

/

Testing the Application and Domain with Unit Tests

Testing the Application and Domain with Unit Tests

Understand unit testing in Go, with a focus on table-driven testing, and utilizing test doubles for thorough code validation.

The system under test for a unit test is the smallest unit we can find in our application. In applications that are written in Go, this unit will be a function or method on a struct:

Press + to interact
The scope of a unit test
The scope of a unit test

As shown in the above figure, only the function code is being tested. Any dependencies that the code under test requires must be provided as a test double such as a mock, a stub, or a fake dependency.

Each test should focus on testing only one path through ...