best way to mock/unit test http.Client?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. gock

    HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽

    github.com/h2non/gock

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. go-vcr

    Record and replay your HTTP interactions for fast, deterministic and accurate tests

    dnaeon/go-vcr

  4. gaia

    Build powerful pipelines in any programming language.

    Something like this: https://github.com/gaia-pipeline/gaia/blob/8a9f66742fbb4c5120e52fcfeef94ff4fcfd63a0/workers/pipeline/git.go#L233

  5. httpmock

    HTTP mocking for Golang

    To mock an API: https://github.com/jarcoal/httpmock to use when your code calls external APIs so you don't want your tests call the real API. No need to create an interface as you do.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Quitting early for the win!

    4 projects | dev.to | 13 Dec 2024
  • Integration Tests in Go with Cucumber, Testcontainers, and HTTPMock

    4 projects | dev.to | 11 Sep 2024
  • Automated Acceptance Testing with Robot Framework and Testkube

    4 projects | dev.to | 3 Jun 2024
  • The Uncreative Software Engineer's Compendium to Testing

    7 projects | dev.to | 31 Jul 2023
  • What tools you use for http load testing?

    6 projects | /r/linuxadmin | 14 Apr 2023

Did you know that Go is
the 4th most popular programming language
based on number of references?