HOME > Development > Introduction to Testing in Go (Golang)

Introduction to Testing in Go (Golang)

  • Development
  • Jan 19, 2025
SynopsisIntroduction to Testing in Go (Golang , available at $84.99,...
Introduction to Testing in Go (Golang)  No.1

Introduction to Testing in Go (Golang), available at $84.99, has an average rating of 4.5, with 120 lectures, based on 510 reviews, and has 6321 subscribers.

You will learn about 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 This course is ideal for individuals who are Developers working in Go who want to level up their testing skills It is particularly useful for Developers working in Go who want to level up their testing skills.

Enroll now: Introduction to Testing in Go (Golang)

Summary

Title: Introduction to Testing in Go (Golang)

Price: $84.99

Average Rating: 4.5

Number of Lectures: 120

Number of Published Lectures: 120

Number of Curriculum Items: 120

Number of Published Curriculum Objects: 120

Original Price: $49.99

Quality Status: approved

Status: Live

What You Will 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 Should Attend

  • Developers working in Go who want to level up their testing skills
  • Target Audiences

  • Developers working in Go who want to level up their testing skills
  • 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 APIbuilt 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 routes

  • Application handlers

  • How to test multiple scenarios by writing and using table tests

  • Database operations (using the Repository pattern)

  • Application middleware

  • User authentication (with sessions)

  • User authentication (with JWT tokens)

  • JWT token generation and validation

  • Refresh token generation and validation

  • Testing user input

  • Writing to the terminal

  • Adding cookies to a request

  • Reading cookies from a response

  • By the end of this course, you will have a solid understanding of how to write effective tests, and how to write testable code.

    Course Curriculum

    Chapter 1: Introduction

    Lecture 1: Introduction

    Lecture 2: About me

    Lecture 3: Asking for help

    Lecture 4: Mistakes: we all make them.

    Chapter 2: Setting up our Development Environment

    Lecture 1: What well cover in this section

    Lecture 2: Installing Go

    Lecture 3: Installing an IDE

    Lecture 4: Installing Docker

    Chapter 3: Simple Testing

    Lecture 1: What well cover in this section

    Lecture 2: Creating a simple command line application

    Lecture 3: Writing a our first test for the isPrime() function

    Lecture 4: Improving our test with table tests

    Lecture 5: Checking test coverage

    Lecture 6: Completing our table tests

    Lecture 7: Improving our program to allow for user entered information

    Lecture 8: Writing a test for the prompt() function

    Lecture 9: Writing a test for the intro() function

    Lecture 10: Testing user input – writing a test for the checkNumbers() function

    Lecture 11: Updating readUserInput to make it testable, and then testing it

    Chapter 4: An Aside: Running individual tests & Test Suites

    Lecture 1: What well cover in this section

    Lecture 2: Running a single test

    Lecture 3: Running groups of tests (test suites)

    Chapter 5: Testing Web Applications

    Lecture 1: What well cover in this section

    Lecture 2: Creating a simple web app

    Lecture 3: Setting up a route and handler for the home page

    Lecture 4: Testing our application routes

    Lecture 5: Testing Handlers: the Home handler

    Lecture 6: Setting up some simple middleware

    Lecture 7: Trying out our new addIPToContext middleware

    Lecture 8: Testing our middleware

    Lecture 9: Testing ipFromContext

    Lecture 10: Creating a login form

    Lecture 11: Setting up a route and stub handler for the login form

    Chapter 6: Testing Validation

    Lecture 1: What well cover in this section

    Lecture 2: Setting up validation logic

    Lecture 3: Testing validation logic

    Lecture 4: Completing the tests for our validation logic

    Lecture 5: Trying out validation with our login form

    Chapter 7: Testing Sessions

    Lecture 1: What well cover in this section

    Lecture 2: Setting up a test enviroment with testing.M

    Lecture 3: Simplifying our templates using a layout

    Lecture 4: Installing a sessions package

    Lecture 5: Adding session to App config, and creating a SessionManager

    Lecture 6: Trying out our sessions

    Lecture 7: Updating our tests

    Lecture 8: Improving our test for the Home handler

    Lecture 9: Testing the render function with a bad template

    Chapter 8: Testing POST handlers

    Lecture 1: What well cover in this section

    Lecture 2: Installing postgres with Docker

    Lecture 3: Setting up a database connection

    Lecture 4: Adding the data package for models and db package for database access

    Lecture 5: Making sure our web app can connect to our database

    Lecture 6: Closing our database pool gracefully, and resetting template path in tests

    Lecture 7: Creating a stub profile page

    Lecture 8: Adding messages to our template data and template files

    Lecture 9: Adding true authentication to the Login handler

    Lecture 10: Testing the Login handler

    Lecture 11: Adding Auth middleware

    Lecture 12: Testing Auth middleware

    Lecture 13: Updating routes & end-to-end tests

    Lecture 14: Problems with our Login handler test

    Chapter 9: The Repository Pattern

    Lecture 1: What well cover in this section

    Lecture 2: Defining an interface type for our repository

    Lecture 3: Moving our database functions into a repository

    Lecture 4: Updating application config to use the database repository

    Lecture 5: Creating a testdb repository

    Lecture 6: Updating setup_test.go to use the test repository

    Lecture 7: Updating our tests to use the testdb repository

    Chapter 10: Testing the database with Integration tests

    Lecture 1: What well cover in this section

    Lecture 2: Getting started with testing our database

    Lecture 3: Getting our tests to spin up a docker image with Postgres

    Lecture 4: Populating our test database with empty tables

    Lecture 5: Testing InsertUser

    Lecture 6: Testing AllUsers

    Lecture 7: Testing GetUser and GetUserByEmail

    Lecture 8: Testing UpdateUser

    Lecture 9: Testing DeleteUser

    Lecture 10: Testing ResetUserPassword

    Lecture 11: Testing InsertUserImage

    Lecture 12: Using build tags to separate our integration tests

    Chapter 11: Testing File Uploads

    Lecture 1: What well cover in this section

    Lecture 2: Adding a form to the Profile page

    Lecture 3: Adding the UserImage type to the User type

    Lecture 4: Updating the profile.page.gohtml file to look for a profile image

    Lecture 5: Writing a stub handler and a function to process profile image uploads

    Lecture 6: Implementing the UploadProfilePic handler

    Lecture 7: Trying things out

    Lecture 8: Testing image uploads

    Lecture 9: Testing our upload handler, with an alternative approach

    Instructors

  • Introduction to Testing in Go (Golang)  No.2
    Trevor Sawler
    Ph.D.
  • Rating Distribution

  • 1 stars: 2 votes
  • 2 stars: 5 votes
  • 3 stars: 30 votes
  • 4 stars: 105 votes
  • 5 stars: 370 votes
  • Frequently Asked Questions

    How long do I have access to the course materials?

    You can view and review the lecture materials indefinitely, like an on-demand channel.

    Can I take my courses with me wherever I go?

    Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don’t have an internet connection, some instructors also let their students download course lectures. That’s up to the instructor though, so make sure you get on their good side!