Go (Golang) httptest Tutorial

preview_player
Показать описание
Go (Golang) httptest Tutorial

In this episode we are going to look at the httptest package and how it can be used to better test our HTTP clients and servers in Go.

Go (Golang) struck me when I first learned about its HTTP testing package. In other programming languages I have been used to have to do a lot of work for testing HTTP servers. In Go (Golang) this isn't the case. There is an amazing testing package that can be used right away from the standard library and it's extremely easy to understand. Let's have a look at how you can use the httptest package and build better end-to-end and http tests for your Go http services.

The idea behind the httptest package is that it' pretty easy to mock an HTTP server or to mock a response writer to feed into our server handlers. This makes it extremely easy to test http servers and clients.

Рекомендации по теме
Комментарии
Автор

Thanks for your awesome videos. I started to learn Go after seeing your videos of the advent of code 2020 and now I'm starting new job working with Go. Thank you very much and keep the good work ☺️

MrEmanuelFeijo
Автор

Please make a video on how to mock the database.. where there is no interfaces and methods in actual code.. the database credentials are in config file.. Please help me.. I have to implement it In my project.

VamsiKrishnaVeloori
join shbcf.ru