Unit Testing in Go

Unit Testing in Go

43mBeginner2023-10-17

Authors

Michael Okuboyejo

Michael Okuboyejo

Course details

The Go programming language, or Golang, includes testing support as part of its standard library. Even though it’s up to you to think carefully about test cases, boundaries, and data structures, Golang supports programmers with a rich testing toolset and comprehensive internal package for testing. In this course, Michael Okuboyejo walks beginner/intermediate Go developers through this internal package and shows how to write, speed up, and structure unit tests in Go. Along the way, Michael offers opportunities to practice your new skills, culminating in a use case that you’ll likely encounter on the job: writing tests for HTTP clients and handlers.

Skills covered

GoSoftware TestingGoogleProgramming LanguagesSoftware DevelopmentOne-Off

Concepts

0. Introduction

  • 01 - Testing in Go

1. Getting Started

  • 02 - What it unit testing and why it matters
  • 03 - How to write unit tests in Go

2. Running Tests in Go

  • 04 - Testing multiple test cases
  • 05 - Running multiple tests in parallel
  • 06 - Best practices - Running tests in Go

3. Helpful Testing Tips

  • 07 - Comparing objects of different types
  • 08 - Test runner flags
  • 09 - Measuring code coverage

4. Mocks

  • 10 - What is mocking
  • 11 - How to mock and fake in Golang
  • 12 - Best practices - Mocking

5. Testing with HTTP

  • 13 - Unit testing HTTP clients
  • 14 - Unit testing HTTP handlers

5. Testing with HTTP

  • 15 - Next steps
40,000 Toman