We may earn an affiliate commission when you visit our partners.
Course image
Federico León

In this course we're covering every aspect of the testing features in Go:

Read more

In this course we're covering every aspect of the testing features in Go:

  • Basic unit tests.

  • Test Driven Development.

  • Unit test a single layer of your application.

  • How to use Go modules.

  • How the TestMain function works and how to use it.

  • Mock and unit test external REST API calls.

  • Mock and integration test REST API calls form inner layers of your application.

  • How to perform functional tests.

  • How to define and write benchmarks to compare the quality of two versions of the same solution.

  • Mock and unit test MySQL database connection and query.

  • Mock frameworks available out there.

  • Asserts in Go: Why don't we have them? How to implement them in a safe way.

Enroll now

What's inside

Learning objectives

  • Unit test basic functions and methods.
  • Unit test external rest api calls.
  • Unit and integration test external rest api calls.
  • Mock and test mysql databases.
  • Integration test every layer of your application.
  • Benchmark functions for performance tests.
  • Debugging and profiling go applications.
  • Code coverage: that diabolic metric.

Syllabus

Introducción

Welcome! Hope you'll get the most of this course! Take a look at the program, let me know the missing content you want to get covered and is not in the list of topics I'm covering here. Let me help you become better at what you do by giving me feedback about your current testing needs. I'll be adding content as soon as you send the topics and they're relevant to everyone out there struggling with tests in this amazing language.

Read more

What is testing, the different types of test (in any programming language you're using, not only Go), what each type of test must and must not do, all the theory you need to have the concepts crystal clear and start improving the quality of your products.

How unit tests are defined, types of unit tests, how to implement them, how to write them and how to execute them.

Don't trust you code's quality on the coverage you get! Make real tests and ensure that you have all three steps (initialization, execution and validation) actually covered with a real and defined criteria.

How integration tests actually work. What is the difference between unit and integration tests and how you can trust these tests to ensure different layers of your application interact in the proper and expected way.

What is a benchmark and how you can implement this type of test while making sure the opportunity cost between two different approaches is the less you can take. How you can measure the performance of a given algorithm and decide whether you use it or not.

In this lesson we're working with tests where the function being tested could timeout and we should check for that particular situation.

The reason why we don't have asserts by default in Go. How you can implement your own or use an external library to do the job for you.

How you can implement REST API calls from your code. A brand new library we've released to the public and we're actually using in our 1000+ productive microservices.

How to mock and test your entire REST integration by using the current library. Make sure every dependency you work with has a mocking feature included.

How to structure your components in a way you can easily mock and test each of them within your application.

Thanks for the feedback! Based on that, I'm uploading this new lesson where you can learn how to design and implement functional tests in your application.

Hope you like the lesson! As always, let me know any comments!

In this lesson we're creating our own SQL client to use in all of our repos.

Repo: https://github.com/federicoleon/sql-client

Adding features to the SQL client library available at https://github.com/federicoleon/sql-client

If you have any questions or comments that are not particularly about the topics treated during this course you can always use the Q&A section and I'll make sure you clear your doubts by publishing content about those topics or issues as well. If you like what you're looking and getting, take a look at my website, there is a lot more in there!

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Covers unit, integration, and functional testing, which are essential practices for ensuring code reliability and maintainability in Go projects
Explores Test Driven Development (TDD), a valuable approach for designing and implementing robust and well-tested Go applications from the outset
Includes benchmarking techniques, enabling developers to measure and optimize the performance of their Go code for efficiency and scalability
Examines mocking frameworks, which are useful for isolating and testing individual components of Go applications without relying on external dependencies
Teaches how to mock and test MySQL database connections, which is relevant for Go developers working with relational databases
Discusses the absence of built-in asserts in Go and provides guidance on implementing custom asserts or using external libraries, which may require additional setup

Save this course

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

Reviews summary

Practical testing in go

According to learners, this course offers a largely positive introduction to testing in Go. Students found the material highly practical and applicable to real-world projects, covering a comprehensive range of testing types from unit to functional. Specific highlights include valuable sections on mocking external dependencies and benchmarks for performance. However, some learners note the course moves at a fast pace and may require prior experience with Go to follow comfortably. The instructor is commended for updating the course based on feedback, indicating active maintenance.
Instructor's take on coverage.
"The lesson on code coverage was interesting, though I didn't fully agree with the strong opinion presented."
"It provided a different perspective on how to think about the code coverage metric, which was thought-provoking."
"Found the instructor's views on coverage metrics unique."
Course updated based on feedback.
"The instructor added a lesson based on my feedback!"
"Appreciated the instructor's responsiveness to questions and suggestions."
"It seems like the course is actively maintained and improved over time."
Useful sections on advanced topics.
"The mocking section for APIs and DBs was very useful and cleared up a lot for me."
"The benchmarks lesson gave me new insights into performance testing."
"I appreciated the coverage of performance testing techniques using benchmarks."
Wide range of testing methods.
"Covered unit, integration, and functional tests well, explaining the differences."
"Appreciated the clear distinction made between different test types."
"It provides a good overview of various testing strategies in Go."
Focus on real-world Go testing.
"The practical examples were really helpful for me."
"I could immediately apply these techniques at work after taking this course."
"The hands-on approach used here really solidified my understanding."
"This course focuses on real-world scenarios, not just theory."
Moves fast, prior Go advised.
"It moves quite fast; I think it would be tough without prior Go experience already."
"I felt it assumed a certain level of Go knowledge and experience."
"Sometimes I felt rushed through some of the basic concepts before moving to complex ones."

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 Unit, integration and functional Testing in Golang (Go) with these activities:
Review Go Fundamentals
Solidify your understanding of Go syntax, data types, and control flow to better grasp testing concepts.
Browse courses on Go Programming Language
Show steps
  • Review the official Go documentation on basic syntax and data types.
  • Practice writing simple Go programs using different control flow structures.
  • Complete online Go tutorials or exercises focusing on fundamentals.
Read 'The Go Programming Language'
Gain a comprehensive understanding of the Go language to write better tests.
Show steps
  • Read the chapters related to testing and concurrency.
  • Study the code examples and try to implement them yourself.
  • Reflect on how the concepts presented in the book relate to testing strategies.
Read 'Go in Action'
Gain a deeper understanding of Go's features and best practices to write more effective tests.
View Go in Action on Amazon
Show steps
  • Read the chapters related to concurrency and networking.
  • Study the code examples and try to implement them yourself.
  • Reflect on how the concepts presented in the book relate to testing strategies.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Implement Mocking Techniques
Practice mocking dependencies in Go to isolate units of code and write effective unit tests.
Show steps
  • Choose a mocking framework like Mockery or GoMock.
  • Create interfaces for external dependencies.
  • Generate mock implementations of those interfaces.
  • Write unit tests using the generated mocks to control the behavior of dependencies.
Build a Simple REST API and Test It
Apply testing techniques learned in the course by building and testing a REST API.
Show steps
  • Design a simple REST API with a few endpoints.
  • Implement the API using Go and a framework like Gin or Echo.
  • Write unit tests for individual handlers and functions.
  • Write integration tests to verify the API endpoints.
Write a Blog Post on Go Testing
Reinforce your understanding of Go testing by explaining key concepts in a blog post.
Show steps
  • Choose a specific topic related to Go testing, such as mocking or TDD.
  • Research the topic and gather relevant information.
  • Write a clear and concise blog post explaining the concept and providing examples.
  • Publish the blog post on a platform like Medium or your own website.
Contribute to a Go Testing Library
Deepen your understanding of Go testing by contributing to an open-source testing library.
Show steps
  • Identify a Go testing library on GitHub that you want to contribute to.
  • Review the library's documentation and contribution guidelines.
  • Find an open issue or propose a new feature related to testing.
  • Implement the changes and submit a pull request.

Career center

Learners who complete Unit, integration and functional Testing in Golang (Go) will develop knowledge and skills that may be useful to these careers:
Test Engineer
A test engineer is responsible for designing and implementing tests to evaluate software quality, and this course provides extensive coverage of the tools and techniques needed to do so using Go. This role requires a strong understanding of different testing types. This course extensively covers unit, integration, and functional testing, and also delves into mocking external APIs and databases, a crucial skill for a test engineer. By learning to use Go's testing features and implementing various testing strategies, test engineers who take this course can enhance their ability to ensure software reliability and performance.
Software Developer
A software developer designs, develops, and tests software applications, and this course is highly relevant for developers who wish to write better code. This role requires a solid understanding of testing methodologies, including unit, integration, and functional testing. This course on testing in Go helps build a foundation in these essential areas, with particular emphasis on writing tests for different parts of your application, including REST API calls and database interactions, and benchmarking to improve performance. The ability to effectively test code is critical to the success of a developer.
API Developer
An API developer designs and builds application programming interfaces, and this course prepares them to ensure their APIs are reliable and performant through testing in Go. This role requires a good understanding of how to mock and test external API calls. This course teaches how to correctly unit test external REST API calls, as well as how to perform integration tests of REST API calls from within your application. The course also teaches how to set up functional tests. With this background, an API developer can be confident in the quality and reliability of their product.
Quality Assurance Engineer
A quality assurance engineer focuses on preventing defects in software, and this course provides the essential knowledge and skills to do so effectively by emphasizing thorough testing practices in Go. This role requires a deep understanding of testing methodologies to ensure the software meets quality standards. This course covers topics such as test driven development, unit testing, integration testing, and functional testing, as well as how to mock external API calls and database queries. A quality assurance engineer, with this background, is well-prepared to write automated tests that confirm the reliability of software.
Backend Engineer
A backend engineer is responsible for the server-side logic and infrastructure of applications, and this course provides a critical skill set by teaching the testing features for applications written in Go. This role requires a strong grasp of testing and debugging techniques to maintain system health. This course delves into unit, integration, and functional testing in Go. It emphasizes mocking database connections and external API calls, all of which are vital for a thorough backend testing strategy. This course also covers benchmarking, which can improve the performance of the system.
DevOps Engineer
A DevOps engineer focuses on the automation of software development lifecycles and infrastructure management, and this course will help them understand how testing fits into the delivery pipeline. This role benefits from a deep understanding of continuous integration and the importance of automated testing. This course teaches fundamental testing practices in Go, which is key for any modern DevOps pipeline. With training in unit, integration, and functional testing, as well as implementation of benchmarks and mocking of external services, a DevOps engineer is well equipped to create automated tests that support continuous delivery.
Site Reliability Engineer
A site reliability engineer is focused on ensuring the reliability and performance of software systems in production, and this course prepares students to build more reliable systems through careful testing. This role requires a thorough understanding of testing methods, and how they relate to system performance. This course goes into depth regarding unit, integration, and functional testing, along with performance benchmarking. These techniques help a site reliability engineer to evaluate and improve the reliability of Go applications. Knowledge of these testing methods can also help spot potential issues before they impact the live environment.
Software Architect
A software architect designs the high-level structure and components of software systems, and this course covers a key aspect of good software design, writing tests. This role benefits from a comprehensive understanding of software reliability and performance. By understanding the testing methodologies covered in this course, software architects can design systems with testability in mind, ensuring robust and maintainable code. The course stresses unit, integration, and functional testing, as well as mocking external dependencies and database interactions, which are crucial for architecting resilient applications.
Technical Lead
A technical lead guides a team of software developers and ensures quality standards are met; this course provides the background to ensure testing standards are upheld. This role requires a solid understanding of software development principles, including testing and code quality. This course teaches different testing strategies in Go, such as unit, integration, and functional testing, as well as mocking external APIs and databases. With this knowledge, a technical lead can guide their team to adopt better testing workflows when using Go, and ensure higher quality products.
Database Engineer
A database engineer is responsible for the design, implementation, and maintenance of databases, and this course provides the foundations of testing data interaction in Go. This role requires a deep understanding of how applications interact with databases and how to test this interaction. This course specifically covers mocking and unit testing MySQL database connections and queries. With a focus on various testing strategies, database engineers are prepared to implement robust testing practices to ensure the reliability of database interactions within applications.
Solutions Architect
A solutions architect translates business needs into technical requirements and designs solutions to meet these requirements; this course will give them a better understanding of the importance of testing in Go. This role needs a firm grasp of the various aspects of software development, including testing methodologies. This course covers unit, integration, and functional testing in Go, along with methods for debugging and benchmarking. A solutions architect who is familiar with the concepts will design more robust and testable software systems.
Embedded Software Engineer
An embedded software engineer develops software for hardware devices, and this course may be useful for those using Go in their work. This role requires attention to detail and a robust testing strategy to ensure code reliability, which this course can help with. This course provides hands-on experience with testing frameworks in Go, covering unit, integration, and functional tests. Using the techniques taught in this course, an embedded software engineer can create more reliable software for hardware devices.
Application Developer
An application developer creates and maintains software applications; this course may be useful for those working on the Go programming language. This role requires a fundamental understanding of testing strategies. This course covers practical testing techniques in Go, like unit testing, integration testing, and functional testing. Application developers who take this training are able to write more robust applications, and can more easily identify and fix bugs. The course's focus on mocking external APIs and database calls is especially helpful.
Mobile Application Developer
A mobile application developer creates applications for mobile devices, and although this course is not specific to mobile development, some platforms may benefit from the Go programming language. This role requires a thorough understanding of different testing strategies. This course provides a foundation in how to use testing features in Go. It covers unit and integration testing and how to benchmark code for performance. While not all mobile applications are built in Go, the skills covered in the course can apply to this role if they are working with Go.
Game Developer
A game developer designs and builds video games, and although this course is not specific to game development, some game engines use the Go programming language. This role requires a good understanding of how to test code and ensure its stability. This course teaches unit, integration, and functional tests, and it also teaches how to mock external calls. Although this course does not focus on game design, it provides fundamental test skills useful for any game developer working on a project that involves Go.

Reading list

We've selected two 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 Unit, integration and functional Testing in Golang (Go).
This book, often referred to as 'The Go Bible,' comprehensive guide to the Go programming language. It covers all aspects of the language, including testing. It provides a solid foundation for understanding the language and its features. is commonly used as a textbook at academic institutions and by industry professionals.
Provides a comprehensive guide to Go programming, covering topics relevant to testing, such as concurrency and networking. It offers practical examples and insights into building robust and scalable applications. While not solely focused on testing, it provides a strong foundation for understanding the context in which tests are written. It valuable resource for intermediate to advanced Go developers.

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