Introduction to Testing in Go (Golang)



Learn how to write effective unit and integration tests in Go, for web applications and REST APIs

5.0 ★ | (12 ratings) | 361 students | Author:Trevor Sawler

Course Duration:

13 sections • 120 lectures • 12h 15m total length


Writing unit tests and integration tests is one of the most-neglected aspects of software development. All too often, a developer will find him or herself say “but it works on my computer!” when a project is presumed finished, only to discover that once taken out of the development environment, things don’t work as expected.Well written unit tests and integration tests help to solve this problem, and in fact almost without exception will reduce overall development time, rather than adding to it. In addition, well-tested code almost always requires less maintenance, and the end product will have less down time.This course is focused on writing unit and integration tests in Go, a modern, type safe, compiled, and extremely fast programming language. It it is ideally suited for building safe, scalable, incredibly fast web applications, and it has powerful testing tools built right in.In this course, we will build four simple applications, and thoroughly test them:A command line application (CLI) that tries to determine if a user-entered number is prime or not;A simple web application that allows a user to log in and upload a profile picture;A simple REST API built on the same code base as the web application which allows users to authenticate using JWT tokens and perform operations against a Postgres database. We’ll go through the entire authentication process, including using refresh tokens, and thoroughly test all aspects of the code.A simple Single Page Web Application (SPA), written in Vanilla JavaScript, that demonstrates how to use JWT and Refresh Tokens with a SPA, and how to test that functionality.For each of these projects, we will learn how to write unit tests for all functionality. We will learn how to test (among other things):Application routesApplication handlersHow to test multiple scenarios by writing and using table testsDatabase operations (using the Repository pattern)Application middlewareUser authentication (with sessions)User authentication (with JWT tokens) JWT token generation and validationRefresh token generation and validationTesting user inputWriting to the terminalAdding cookies to a requestReading cookies from a responseBy the end of this course, you will have a solid understanding of how to write effective tests, and how to write testable code.


#A basic understanding of to use Go programming language

What you’ll learn:

#Learn how to write unit tests in Go
#Learn how to write integration tests in Go, and simplify them using Docker
#Learn how to create test suites in Go
#Learn how to create a simple web application and test handlers, middleware, database, and more
#Learn how to create a simple REST API in Go and test its endpoints
#Learn to to authenticate using JWT Tokens (and refresh tokens) and completely test all functionality
#Learn how to write tests that cover multiple scenarios with table tests

Who this course is for:

#Developers working in Go who want to level up their testing skills



Protected Area

This content is password-protected. Please verify with a password to unlock the content.

Notes: If this Author or Course helped you improve your life. It is really worth it if you go and buy his/her course. Get feedback, support and help by his/her community. The Author support is much more valuable than the course itself.

Leave A Reply

Your email address will not be published.