We may earn an affiliate commission when you visit our partners.
Trevor Sawler

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.

Read more

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 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.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • 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

Syllabus

An overview of the course, and a bit about me.
Introduction
About me
Asking for help
Read more

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Explores modern frameworks and tools for writing tests
Provides the theoretical and practical knowledge to write effective tests in the Go programming language
Offers hands-on experience with building and testing web applications
Delves into the intricacies of authentication using JWT tokens
Includes table tests to improve test coverage
Teaches advanced concepts such as database testing using the Repository pattern

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Introduction to Testing in Go (Golang) with these activities:
Review previous coursework on testing concepts
Recalling foundational knowledge will strengthen your understanding and provide a solid base for this course.
Browse courses on Unit Testing
Show steps
  • Go through old textbooks, notes, or online resources
  • Focus on reviewing basic concepts and principles of testing
Practice writing a variety of unit tests
Writing unit tests is a crucial aspect of software development and is closely related to concepts covered in this course.
Browse courses on Unit Tests
Show steps
  • Create a simple Go program and write unit tests for each function
  • Try using different types of assertions to check for various conditions
  • Experiment with table tests for scenarios with multiple inputs
Contribute to an open-source Go testing project
Contributing to open source projects allows you to learn from experienced developers and directly impact the community.
Browse courses on Open Source
Show steps
  • Identify an open-source Go testing project to contribute to
  • Study the project's codebase and documentation
  • Identify areas where you can make improvements or add features
  • Create pull requests with your proposed changes
  • Review feedback from maintainers and revise your pull requests
  • Attend online or local meetups related to open-source projects
Four other activities
Expand to see all activities and additional details
Show all seven activities
Read 'Go Testing' by Brad Fitzpatrick
This book provides in-depth information on unit testing best practices in Go.
Show steps
  • Obtain a copy of the book 'Go Testing'
  • Read and understand the concepts presented in the book
  • Apply the learnings from the book to your own Go projects
Build a simple web application and test it
This activity ties directly to the course content and allows you to apply your knowledge to a more practical setting.
Browse courses on Web Applications
Show steps
  • Create a new web application in Go
  • Implement basic functionality like handling HTTP requests and rendering templates
  • Write unit and integration tests to ensure the application behaves as expected
  • Deploy the application to a cloud platform
Write a blog post about unit testing in Go
Teaching others reinforces your understanding and allows you to think critically about the concepts learned in this course.
Show steps
  • Choose a specific aspect of unit testing in Go to focus on
  • Research the topic and gather relevant information
  • Write a clear and concise blog post explaining the topic
  • Publish the blog post on a platform like Medium or Dev.to
  • Share the blog post on social media and engage with readers
Develop a code repository that demonstrates your knowledge
Creating a code repository showcases your skills and allows you to share them with potential employers and collaborators.
Show steps
  • Choose a specific project or set of projects to highlight
  • Organize your code in a GitHub repository using branches and pull requests
  • Write clear documentation and provide detailed commit messages
  • Make your repository publicly available on GitHub
  • Share your repository on social media and engage with other developers (optional)

Career center

Learners who complete Introduction to Testing in Go (Golang) will develop knowledge and skills that may be useful to these careers:
Quality Assurance Tester
Quality Assurance Testers perform testing activities to ensure that software meets its requirements and user expectations. This course is particularly helpful for aspiring QA testers interested in the field of software testing as it provides a comprehensive introduction to writing effective tests and understanding the principles that underscore software testability.
Test Analyst
Test analysts plan, develop, and execute test plans. They work to ensure that the end user has a positive experience with a software application. As such, this course is a great fit for someone looking to become a test analyst, since it explores a variety of testing methodologies and best practices within the context of writing unit and integration tests in Go.
Software Developer
Software developers are responsible for designing, developing, and maintaining computer software. This course will help software developers write effective unit and integration tests. Ultimately, this reduces the amount of time and effort required for maintenance and debugging.
Web Developer
Web developers are responsible for building and maintaining websites. This course will help web developers who wish to focus on back-end development within web applications, as it teaches the fundamentals of the Go programming language.
Database Administrator
Database administrators are responsible for the installation, configuration, maintenance, and performance monitoring of databases. This course will help aspiring database administrators who wish to work with relational databases written in Go.
Software Engineer
Software engineers design, develop, and maintain computer software, a vital role for any organization utilizing technological solutions. This course may be useful for a software engineer who seeks to work on back-end development within web applications. Learning how to write tests can lead to more reliable, stable software.
DevOps Engineer
DevOps engineers work to bridge the gap between development and operations teams, enabling faster and more reliable software delivery. This course may be useful for a DevOps engineer who wishes to enhance their testing skills.
Security Engineer
Security engineers are responsible for protecting computer systems and networks from unauthorized access and cyberattacks. This course may be useful for a Security engineer who wishes to gain hands-on experience with testing web applications.
Cloud Architect
Cloud architects design, build, and manage cloud computing solutions. This course may be useful for a cloud architect who wishes to apply testing principles within the domain of cloud computing.
Data Analyst
Data analysts collect, analyze, and interpret data to help organizations make informed decisions. This course may be useful for a data analyst who wishes to improve their data quality by testing for quality assurance prior to analysis.
Product Manager
Product managers are responsible for the development and launch of new products. This course may be useful for a product manager who needs to understand how software development can be automated.
Business Analyst
Business analysts bridge the gap between business and IT, helping to ensure that software meets the needs of the business. This course may be useful for a business analyst who wishes to gain a better understanding of the software development process.
UX Designer
UX designers are responsible for the user experience of software products. This course may be useful for a UX designer who wishes to gain a better understanding of how software is developed.
IT Manager
IT managers are responsible for the planning, implementation, and management of IT systems. This course may be useful for an IT manager who wishes to gain a better understanding of software development and testing practices.
Technical Writer
Technical writers are responsible for creating documentation for software products. This course may be useful for a technical writer who wishes to gain a better understanding of the software development process.

Reading list

We've selected seven books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Introduction to Testing in Go (Golang).
Comprehensive guide to the Go programming language, and it valuable resource for anyone who wants to learn more about Go. It covers the basics of the language, as well as more advanced topics such as concurrency and testing.
Provides a comprehensive overview of testing in Go. It covers topics such as unit testing, integration testing, and performance testing.
Provides a collection of best practices for writing Go code. It covers topics such as code organization, error handling, testing, and concurrency.
Practical guide to writing Go code. It covers topics such as web development, concurrency, and testing. It valuable resource for anyone who wants to learn how to build real-world Go applications.
Provides a collection of blueprints for building common web applications in Go. It covers topics such as HTTP requests and responses, routing, middleware, and templates.
Provides a comprehensive overview of the Go programming language. It covers topics such as syntax, data types, control flow, functions, methods, and packages, as well as more advanced topics such as concurrency, channels, and interfaces.
This cheat sheet provides a quick reference to the Go programming language. It covers topics such as syntax, data types, control flow, functions, methods, and packages.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser