HTTP mocking for Golang

httpmock Build Status Coverage Status GoDoc Version Mentioned in Awesome Go

Easy mocking of http responses from external resources.

Install

Currently supports Go 1.7 - 1.15.

v1 branch has to be used instead of master.

Using go modules (aka. go mod)

In your go files, simply use:

import "github.com/jarcoal/httpmock"

Then next go mod tidy or go test invocation will automatically populate your go.mod with the last httpmock release, now Version.

Note you can use go mod vendor to vendor your dependencies.

Using $GOPATH

v1 branch is configured as the default branch in github, so:

go get github.com/jarcoal/httpmock

automatically downloads the v1 branch in $GOPATH/src. Then in your go files use:

import "github.com/jarcoal/httpmock"

Vendoring, using govendor for example

When vendoring is used, v1 branch has to be specified. Two choices here:

  • preferred way:
    govendor fetch github.com/jarcoal/httpmock@v1
    
    then in go files:
    import "github.com/jarcoal/httpmock"
  • old way (before v1 was set as default branch), use gopkg to read from v1 branch:
    govendor fetch gopkg.in/jarcoal/httpmock.v1
    
    then in go files:
    import "gopkg.in/jarcoal/httpmock.v1"

Usage

Simple Example:

func TestFetchArticles(t *testing.T) {
  httpmock.Activate()
  defer httpmock.DeactivateAndReset()

  // Exact URL match
  httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles",
    httpmock.NewStringResponder(200, `[{"id": 1, "name": "My Great Article"}]`))

  // Regexp match (could use httpmock.RegisterRegexpResponder instead)
  httpmock.RegisterResponder("GET", `=~^https://api\.mybiz\.com/articles/id/\d+\z`,
    httpmock.NewStringResponder(200, `{"id": 1, "name": "My Great Article"}`))

  // do stuff that makes a request to articles
  ...

  // get count info
  httpmock.GetTotalCallCount()

  // get the amount of calls for the registered responder
  info := httpmock.GetCallCountInfo()
  info["GET https://api.mybiz.com/articles"] // number of GET calls made to https://api.mybiz.com/articles
  info["GET https://api.mybiz.com/articles/id/12"] // number of GET calls made to https://api.mybiz.com/articles/id/12
  info[`GET =~^https://api\.mybiz\.com/articles/id/\d+\z`] // number of GET calls made to https://api.mybiz.com/articles/id/<any-number>
}

Advanced Example:

func TestFetchArticles(t *testing.T) {
  httpmock.Activate()
  defer httpmock.DeactivateAndReset()

  // our database of articles
  articles := make([]map[string]interface{}, 0)

  // mock to list out the articles
  httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles",
    func(req *http.Request) (*http.Response, error) {
      resp, err := httpmock.NewJsonResponse(200, articles)
      if err != nil {
        return httpmock.NewStringResponse(500, ""), nil
      }
      return resp, nil
    },
  )

  // return an article related to the request with the help of regexp submatch (\d+)
  httpmock.RegisterResponder("GET", `=~^https://api\.mybiz\.com/articles/id/(\d+)\z`,
    func(req *http.Request) (*http.Response, error) {
      // Get ID from request
      id := httpmock.MustGetSubmatchAsUint(req, 1) // 1=first regexp submatch
      return httpmock.NewJsonResponse(200, map[string]interface{}{
        "id":   id,
        "name": "My Great Article",
      })
    },
  )

  // mock to add a new article
  httpmock.RegisterResponder("POST", "https://api.mybiz.com/articles",
    func(req *http.Request) (*http.Response, error) {
      article := make(map[string]interface{})
      if err := json.NewDecoder(req.Body).Decode(&article); err != nil {
        return httpmock.NewStringResponse(400, ""), nil
      }

      articles = append(articles, article)

      resp, err := httpmock.NewJsonResponse(200, article)
      if err != nil {
        return httpmock.NewStringResponse(500, ""), nil
      }
      return resp, nil
    },
  )

  // do stuff that adds and checks articles
}

Algorithm

When GET http://example.tld/some/path?b=12&a=foo&a=bar request is caught, all standard responders are checked against the following URL or paths, the first match stops the search:

  1. http://example.tld/some/path?b=12&a=foo&a=bar (original URL)
  2. http://example.tld/some/path?a=bar&a=foo&b=12 (sorted query params)
  3. http://example.tld/some/path (without query params)
  4. /some/path?b=12&a=foo&a=bar (original URL without scheme and host)
  5. /some/path?a=bar&a=foo&b=12 (same, but sorted query params)
  6. /some/path (path only)

If no standard responder matched, the regexp responders are checked, in the same order, the first match stops the search.

Ginkgo Example:

// article_suite_test.go

import (
  // ...
  "github.com/jarcoal/httpmock"
)
// ...
var _ = BeforeSuite(func() {
  // block all HTTP requests
  httpmock.Activate()
})

var _ = BeforeEach(func() {
  // remove any mocks
  httpmock.Reset()
})

var _ = AfterSuite(func() {
  httpmock.DeactivateAndReset()
})


// article_test.go

import (
  // ...
  "github.com/jarcoal/httpmock"
)

var _ = Describe("Articles", func() {
  It("returns a list of articles", func() {
    httpmock.RegisterResponder("GET", "https://api.mybiz.com/articles.json",
      httpmock.NewStringResponder(200, `[{"id": 1, "name": "My Great Article"}]`))

    // do stuff that makes a request to articles.json
  })
})

Ginkgo + Resty Example:

// article_suite_test.go

import (
  // ...
  "github.com/jarcoal/httpmock"
  "github.com/go-resty/resty"
)
// ...
var _ = BeforeSuite(func() {
  // block all HTTP requests
  httpmock.ActivateNonDefault(resty.DefaultClient.GetClient())
})

var _ = BeforeEach(func() {
  // remove any mocks
  httpmock.Reset()
})

var _ = AfterSuite(func() {
  httpmock.DeactivateAndReset()
})


// article_test.go

import (
  // ...
  "github.com/jarcoal/httpmock"
  "github.com/go-resty/resty"
)

var _ = Describe("Articles", func() {
  It("returns a list of articles", func() {
    fixture := `{"status":{"message": "Your message", "code": 200}}`
    responder := httpmock.NewStringResponder(200, fixture)
    fakeUrl := "https://api.mybiz.com/articles.json"
    httpmock.RegisterResponder("GET", fakeUrl, responder)

    // fetch the article into struct
    articleObject := &models.Article{}
    _, err := resty.R().SetResult(articleObject).Get(fakeUrl)

    // do stuff with the article object ...
  })
})
Comments
  • Capture the request body

    Capture the request body

    I think is not hard adds a Responder who capture the request body. I would like validate the request who arrive in http server. Something like that:

    func NewCaptureResponder(captor *Captor, res *http.Response) func(req *http.Request) (*http.Response, error) {
    	return func(req *http.Request) (*http.Response, error) {
    		buf := bytes.Buffer{}
    		_, err := io.Copy(&buf, req.Body)
    		if err != nil {
    			return nil, err
    		}
    		captor.Value = buf.String()
    		return res, nil
    	}
    }
    
    requestCaptor := Captor{}
    responder := NewCaptureResponder(&requestCaptor, httpmock.NewStringResponse(tt.givenStatus, tt.givenResponse))
    				httpmock.RegisterResponder(tt.givenMethod, tt.givenUrl, responder)
    

    What you think about? Make sense? If you agree. I could submit a pull request with that.

  • Data Race Issue

    Data Race Issue

    Let me start by saying, this might be entirely my fault, and I barely understand anything about Go.

    I'm attempting to convert a test from using a pretty ugly chunk of httptest code to httpmock:

    https://github.com/dropbox/changes-client/compare/handle-abortions...httpmock

    However, upon doing this we hit a race which only presents itself with httpmock:

    ==================
    WARNING: DATA RACE
    Write by goroutine 7:
      github.com/jarcoal/httpmock.Deactivate()
          /home/vagrant/src/github.com/jarcoal/httpmock/transport.go:139 +0x51
      github.com/jarcoal/httpmock.DeactivateAndReset()
          /home/vagrant/src/github.com/jarcoal/httpmock/transport.go:150 +0x2b
      github.com/dropbox/changes-client/engine.TestCompleteFlow()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine_test.go:296 +0x1b4c
      testing.tRunner()
          /usr/local/go/src/pkg/testing/testing.go:422 +0x10f
    
    Previous read by goroutine 11:
      net/http.(*Client).send()
          /usr/local/go/src/pkg/net/http/client.go:118 +0x39e
      net/http.(*Client).doFollowingRedirects()
          /usr/local/go/src/pkg/net/http/client.go:343 +0xd31
      net/http.(*Client).Get()
          /usr/local/go/src/pkg/net/http/client.go:275 +0xcd
      net/http.Get()
          /usr/local/go/src/pkg/net/http/client.go:252 +0x6e
      github.com/dropbox/changes-client/engine.(*UpstreamMonitor).fetchJobStep()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/upstream_monitor.go:55 +0x151
      github.com/dropbox/changes-client/engine.(*UpstreamMonitor).WaitUntilAbort()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/upstream_monitor.go:33 +0x6c
      github.com/dropbox/changes-client/engine.func·005()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:213 +0x95
    
    Goroutine 7 (running) created at:
      testing.RunTests()
          /usr/local/go/src/pkg/testing/testing.go:504 +0xb46
      testing.Main()
          /usr/local/go/src/pkg/testing/testing.go:435 +0xa2
      main.main()
          github.com/dropbox/changes-client/engine/_test/_testmain.go:47 +0xdc
    
    Goroutine 11 (running) created at:
      github.com/dropbox/changes-client/engine.(*Engine).runBuildPlan()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:217 +0x8c9
      github.com/dropbox/changes-client/engine.(*Engine).Run()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:75 +0x1e5
      github.com/dropbox/changes-client/engine.RunBuildPlan()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:59 +0x1a8
      github.com/dropbox/changes-client/engine.TestCompleteFlow()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine_test.go:196 +0xb7b
      testing.tRunner()
          /usr/local/go/src/pkg/testing/testing.go:422 +0x10f
    ==================
    ==================
    WARNING: DATA RACE
    Write by goroutine 7:
      github.com/jarcoal/httpmock.Reset()
          /home/vagrant/src/github.com/jarcoal/httpmock/transport.go:144 +0x4e
      github.com/jarcoal/httpmock.DeactivateAndReset()
          /home/vagrant/src/github.com/jarcoal/httpmock/transport.go:151 +0x30
      github.com/dropbox/changes-client/engine.TestCompleteFlow()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine_test.go:296 +0x1b4c
      testing.tRunner()
          /usr/local/go/src/pkg/testing/testing.go:422 +0x10f
    
    Previous read by goroutine 11:
      github.com/jarcoal/httpmock.(*MockTransport).responderForKey()
          /home/vagrant/src/github.com/jarcoal/httpmock/transport.go:63 +0x43
      github.com/jarcoal/httpmock.(*MockTransport).RoundTrip()
          /home/vagrant/src/github.com/jarcoal/httpmock/transport.go:41 +0x10e
      net/http.send()
          /usr/local/go/src/pkg/net/http/client.go:195 +0x62d
      net/http.(*Client).send()
          /usr/local/go/src/pkg/net/http/client.go:118 +0x200
      net/http.(*Client).doFollowingRedirects()
          /usr/local/go/src/pkg/net/http/client.go:343 +0xd31
      net/http.(*Client).Get()
          /usr/local/go/src/pkg/net/http/client.go:275 +0xcd
      net/http.Get()
          /usr/local/go/src/pkg/net/http/client.go:252 +0x6e
      github.com/dropbox/changes-client/engine.(*UpstreamMonitor).fetchJobStep()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/upstream_monitor.go:55 +0x151
      github.com/dropbox/changes-client/engine.(*UpstreamMonitor).WaitUntilAbort()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/upstream_monitor.go:33 +0x6c
      github.com/dropbox/changes-client/engine.func·005()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:213 +0x95
    
    Goroutine 7 (running) created at:
      testing.RunTests()
          /usr/local/go/src/pkg/testing/testing.go:504 +0xb46
      testing.Main()
          /usr/local/go/src/pkg/testing/testing.go:435 +0xa2
      main.main()
          github.com/dropbox/changes-client/engine/_test/_testmain.go:47 +0xdc
    
    Goroutine 11 (running) created at:
      github.com/dropbox/changes-client/engine.(*Engine).runBuildPlan()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:217 +0x8c9
      github.com/dropbox/changes-client/engine.(*Engine).Run()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:75 +0x1e5
      github.com/dropbox/changes-client/engine.RunBuildPlan()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine.go:59 +0x1a8
      github.com/dropbox/changes-client/engine.TestCompleteFlow()
          /home/vagrant/src/github.com/dropbox/changes-client/engine/engine_test.go:196 +0xb7b
      testing.tRunner()
          /usr/local/go/src/pkg/testing/testing.go:422 +0x10f
    ==================
    
  • Implemented test case with mock. but it's not working

    Implemented test case with mock. but it's not working

    I implemented a code to get data from the API. And also wrote the test case with mock to that method by using https://github.com/jarcoal/httpmock. But mocking was not executing. Getting original data from the data. not getting mock data. tried in all the ways. but not working. can anyone help me please?

    func MakeAPIRequest(url string) ([]byte, error) {
        req, err := http.NewRequest(http.MethodGet, url, nil)
        if err != nil {
            log.Fatal(err)
        }
        tr := &http.Transport{
            TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
        }
        httpClient := &http.Client{Transport: tr}
        response, err := httpClient.Do(req)
        if err != nil {
            log.Fatal(err)
        }
        defer response.Body.Close()
        body, err := ioutil.ReadAll(response.Body)
        if err != nil {
            log.Fatal(err)
        }
        return body, nil
    }
    

    Test case code Is

    func TestMakeAPIRequest(t *testing.T) {
        httpmock.Activate()
        defer httpmock.DeactivateAndReset()
        httpmock.RegisterResponder("GET", "https://jsonplaceholder.typicode.com/users/1",
            httpmock.NewStringResponder(200, `{
                "id": 1,
                "name": "Leanne Graham Test Name",
                "username": "Bret",
                "email": "[email protected]",
                "address": {
                  "street": "Kulas Light",
                  "suite": "Apt. 556",
                  "city": "Gwenborough",
                  "zipcode": "92998-3874",
                  "geo": {
                    "lat": "-37.3159",
                    "lng": "81.1496"
                  }
                },
                "phone": "1-770-736-8031 x56442",
                "website": "hildegard.org",
                "company": {
                  "name": "Romaguera-Crona",
                  "catchPhrase": "Multi-layered client-server neural-net",
                  "bs": "harness real-time e-markets"
                }
              }`))
    
        data, err := MakeAPIRequest("https://jsonplaceholder.typicode.com/users/1")
        fmt.Println("data:", string(data), err)
        fmt.Println(httpmock.GetCallCountInfo())
    }
    

    getting 0 when call fmt.Println(httpmock.GetCallCountInfo())

    https://stackoverflow.com/questions/64769575/implemented-test-case-with-mock-but-its-not-working

  • Request do not propagate to package functions

    Request do not propagate to package functions

    I'm trying to mock a URL that a function requests at the package I'm testing and it still executes the request to the original URL instead of the mocked one that we defined. Is there support for acessing mocked urls at package functions or only inside the test?

    mockedResponse := map[string]interface{}{
            "data": []map[string]interface{}{
                map[string]interface{}{
                    "key": "pipitchu",
                },
            },
            "message": nil,
            "success": true,
        }
    
            url := "https://test.pipitchu.com/123"
        httpmock.RegisterResponder("GET", url,
            func(req *http.Request) (*http.Response, error) {
                resp, err := httpmock.NewJsonResponse(200, mockedResponse)
                if err != nil {
                    return httpmock.NewStringResponse(500, ""), nil
                }
                return resp, nil
            },
        )
    
    key, err := GetKey(123456)
    // key is the "key" key of the first element of the data array
    assert(t, "pipitchu", key)
    // we're using testify
    

    Thanks in advance!

  • Travis-ci: added support for ppc64le

    Travis-ci: added support for ppc64le

    Signed-off-by: Devendranath Thadi [email protected]

    Added power support for the travis.yml file with ppc64le. This is part of the Ubuntu distribution for ppc64le. This helps us simplify testing later when distributions are re-building and re-releasing.

  • Unable to emulate the http mock server

    Unable to emulate the http mock server

    I followed the instructions given on the readme to setup a mock http server. However when I run the test I always get host not found exception which is the result that my httpclient instead of connecting to the mock server is trying to connect to an actual server.

    Please advice.

    Great work by the way

  • No respond for URL question

    No respond for URL question

    I am using httpmock for testing my REST client recently.

    The version of httpmock is github.com/jarcoal/httpmock v1.0.8

    I have a piece of test code, it looks not that complicated, but it always panic 2021/12/16 22:17:24 Response err:Get "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123": no responder found

    The test code is like below:

    func TestGetResources(t *testing.T) {
    	httpmock.Activate()
    	defer httpmock.DeactivateAndReset()
    
    	host := "test.com"
    	path := "/ltm/test_resources/"
    	username := "admin"
    	password := "password"
    	inscure := true
    
    	se := InitSession(host, username, password, inscure)
    	se.Client = &http.Client{}
    	serv := Service{
    		Path:    path,
    		Session: se,
    	}
    	partition := "Project_test123"
    	// url := "https://" + host + serv.URIForPartition(partition)
    	// url := `https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123` (not work)
    	url := "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123"
    	// url := "/ltm/test_resources" (not work)
    
    	resp := []byte("hello")
    
            // I register a byte responder for
            // URL  "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123"
    	httpmock.RegisterResponder(
    		"GET", url, httpmock.NewBytesResponder(200, resp),
    	)
    
    	body := serv.GetResources(partition)
    
    	assert.Equal(t, *body, resp)
    
    }
    

    when I run the test, it always returns panic:

    === RUN   TestGetResources
    2021/12/16 22:17:24 Get Reousrces
    2021/12/16 22:17:24 Request URL is: https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123
    2021/12/16 22:17:24 Response err:Get "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123": no responder found
    --- FAIL: TestGetResources (0.00s)
    panic: Repsonse err:Get "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123": no responder found [recovered]
            panic: Repsonse err:Get "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123": no responder found
    

    As you can see I log the Request URL is: https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123, it is the same as I registered for the Responder.

    Request URL is: https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123
            url := "https://test.com/ltm/test_resources/?$filter=partition%20eq%20Project_test123"
    

    I referred to this issue #106 to try to use /ltm/test_resources to match any path with it. it does not work either.

  • Mock not working

    Mock not working

    I have my http client using transport : [ client := &http.Client{Transport: tr} ]. When I do a mock on this, it fails. Whereas if I remove the transport [ client := &http.Client{} ], it works. Could you please explain a solution to this issue ?

  • Issue while using ActivateNonDefault

    Issue while using ActivateNonDefault

    I'm using ActivateNonDefault for activating the mocks on my custom client but I see it not intercepting the calls. My client is using http.DefaultTransport for transport which I'm passing client := &http.Client{Transport: http.DefaultTransport} httpmock.ActivateNonDefault(client) while activating the client.,I also tried passing the way it is in documentation which did not help me., Can someone help me.,Thanks in advance!

  • Query paramter with no value

    Query paramter with no value

    Recent change #50 in the v1 branch breaks the behavior of query parameter without values. Query parameter with no value is valid due to RFC 3986. Here's a patch to test the case.

    --- a/transport_test.go
    +++ b/transport_test.go
    @@ -217,6 +217,9 @@ func TestMockTransportPathOnlyFallback(t *testing.T) {
     		"/hello/world?query=string&query=string2": {
     			testUrl + "hello/world?query=string&query=string2",
     		},
    +		"/hello/world?query": {
    +			testUrl + "hello/world?query",
    +		},
     		"/hello/world#fragment": {
     			testUrl + "hello/world#fragment",
     		},
    

    Ping to the related patch authors: @konalegi (for #50), @Zanadar (for #55) and @maxatome (for #61)

  • Address query sort issues

    Address query sort issues

    A recent change to HTTP mock added some code that allowed Registering a responder with a query where query order does not matter. This was a great change, but the implementation had an issue: it is perfectly valid for multiple query params to have the same key. Languages and HTTP libraries handle this situation in various ways, but in Go, the standard library handles it by combining the values into a slice. Thus:

    func main() {
    	u, err := url.Parse("http://bing.com/search?q=dotnet&q=aaa")
    	if err != nil {
    		log.Fatal(err)
    	}
    	fmt.Println(u.Query())
    	
    }
    
    $ map[q:[dotnet aaa]]
    

    https://play.golang.org/p/x0P-dhI85sh

    In addressing this problem, I discovered another issue. Existing code was sorting Querys and considering urls with query params in different order to be different. Reasonable people could disagree about this, but there seems to be general consensus that this second part (considering order of query params as significant) is incorrect. If you think of a query as a map of keys to values (which is the type used internally in Go), order does not enter into it. Image a server dealing with multiple params. It wouldn't care about their order in general. It would treat the keys and values as individual query and handle them in a transparent order that callers would never know or care about.

    Thus, I submit this PR with the following intent:

    Instead of have callers of RegisterResponder care about query order and adding new methods to get around this confusion, RoundTrip and RegisterResponder should canonicalize querys, using the Go standard libraries url.Query().Encode() to avoid confusion around query param order. Thus all urls containing the same query params, whatever the order, will be considered equivalent for matching to responders.

  • Question: how to sponsor this project?

    Question: how to sponsor this project?

    Hi 👋 ,

    Thanks so much for the work on this project! At @Reviewpad, we are trying to support the OSS projects that we use as dependencies to our main repository reviewpad/reviewpad.

    Do you plan to join any sponsoring program? We are also happy to help the community to maintain the project.

    Thanks!

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

gock Versatile HTTP mocking made easy in Go that works with any net/http based stdlib implementation. Heavily inspired by nock. There is also its Pyth

Jan 4, 2023
HTTP mocking to test API services for chaos scenarios
HTTP mocking to test API services for chaos scenarios

GAOS HTTP mocking to test API services for chaos scenarios Gaos, can create and provide custom mock restful services via using your fully-customizable

Nov 5, 2022
A simple and expressive HTTP server mocking library for end-to-end tests in Go.

mockhttp A simple and expressive HTTP server mocking library for end-to-end tests in Go. Installation go get -d github.com/americanas-go/mockhttp Exa

Dec 19, 2021
Go Interface Mocking Tool

Charlatan Percolate's Go Interface Mocking Tool. Please read our introductory blog post. Installation go get github.com/percolate/charlatan Usage c

Nov 3, 2022
GoMock is a mocking framework for the Go programming language.

gomock GoMock is a mocking framework for the Go programming language. It integrates well with Go's built-in testing package, but can be used in other

Dec 28, 2022
A clipboard-based mocking framework for Go that gets out of your way.
A clipboard-based mocking framework for Go that gets out of your way.

A clipboard-based mocking framework for Go that gets out of your way. This tool has been built with inspiration lovingly taken from Moq, and fuelled b

Nov 18, 2022
Full-featured test framework for Go! Assertions, mocking, input testing, output capturing, and much more! 🍕
Full-featured test framework for Go! Assertions, mocking, input testing, output capturing, and much more! 🍕

testza ?? Testza is like pizza for Go - you could life without it, but why should you? Get The Module | Documentation | Contributing | Code of Conduct

Dec 10, 2022
Interface mocking tool for go generate
Interface mocking tool for go generate

Interface mocking tool for go generate. What is Moq? Moq is a tool that generates a struct from any interface. The struct can be used in test code as

Jan 5, 2023
HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

govcr A Word Of Warning I'm in the process of partly rewriting govcr to offer better support for cassette mutations. This is necessary because when I

Dec 28, 2022
Golang HTTP client testing framework

flute Golang HTTP client testing framework Presentation https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework Overview flute is the

Sep 27, 2022
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs
Extremely flexible golang deep comparison, extends the go testing package and tests HTTP APIs

go-testdeep Extremely flexible golang deep comparison, extends the go testing package. Latest news Synopsis Description Installation Functions Availab

Dec 22, 2022
Simple HTTP integration test framework for Golang

go-itest Hassle-free REST API testing for Go. Installation go get github.com/jefflinse/go-itest Usage Create tests for your API endpoints and run the

Jan 8, 2022
Http test server written in Golang.

Dummy Server Http test server written in Golang. Can get any request method and log headers, body, path and remote address. Useful if you need to know

Oct 31, 2021
Expressive end-to-end HTTP API testing made easy in Go

baloo Expressive and versatile end-to-end HTTP API testing made easy in Go (golang), built on top of gentleman HTTP client toolkit. Take a look to the

Dec 13, 2022
http integration test framework

go-hit hit is an http integration test framework written in golang. It is designed to be flexible as possible, but to keep a simple to use interface f

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

go-vcr go-vcr simplifies testing by recording your HTTP interactions and replaying them in future runs in order to provide fast, deterministic and acc

Dec 25, 2022
End-to-end HTTP and REST API testing for Go.

httpexpect Concise, declarative, and easy to use end-to-end HTTP and REST API testing for Go (golang). Basically, httpexpect is a set of chainable bui

Jan 5, 2023
Mock object for Go http.ResponseWriter

mockhttp -- Go package for unit testing HTTP serving Unit testing HTTP services written in Go means you need to call their ServeHTTP receiver. For thi

Sep 27, 2022
HTTP load testing tool and library. It's over 9000!
HTTP load testing tool and library. It's over 9000!

Vegeta Vegeta is a versatile HTTP load testing tool built out of a need to drill HTTP services with a constant request rate. It can be used both as a

Jan 7, 2023