Unit Integration And Functional Testing In Golang Go

Everything you'll need to completely test your Go applications

Last updated 2022-01-10 | 3.9

- Unit test basic functions and methods.
- Unit test external REST API calls.
- Unit and integration test external REST API calls.

What you'll learn

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.

* Requirements

* Just complete the Official Go Tour available at Go's homepage

Description

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.

Who this course is for:

  • Software engineers.
  • Software developers.
  • Technical Leaders.
  • Software Architects.
  • QA engineers.

Course content

6 sections • 15 lectures

Welcome! Preview 04:42

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.

Introduction to testing Preview 27:15

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.

Basic unit tests Preview 19:26

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

Code Coverage - The diabolic metric Preview 19:20

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.

Basic integration tests Preview 21:29

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.

Basic benchmarks Preview 33:25

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.

How to test functions with timeout Preview 11:53

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

Asserts: Missing by design Preview 13:39

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.

Testing REST API calls Preview 55:40

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.

Mock and unit test external REST API calls Preview 29:14

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.

Mocking entire layers of the application Preview 54:04

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

Functional testing Preview 45:57

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!

How to test SQL clients Preview 35:45

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


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

Add query features to our client Preview 01:00:24

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

Extra class - Take a look at my website Preview 03:31

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!