Unit Testing a Web App

Learn to write unit tests to test the business logic and handlers for our web app.

Unit testing

In earlier lessons, we created the package coffee for our app, which has the functions to list the coffee menu and to check if a particular type of coffee is available.

Let's try to test the latter function using unit tests. For this, we'll create a file called coffee_test.go under the coffee directory. The structure of the project becomes the following:

Get hands-on with 1200+ tech skills courses.