16 best Go Mock libraries in 2024

share link

by marketing.admin@openweaver.com dot icon Updated: Mar 12, 2023

technology logo
technology logo

Guide Kit Guide Kit  

Mocking is a process used in unit testing when the unit being tested has external dependencies. The purpose of mocking is to isolate and focus on the code being tested and not on the behavior or state of external dependencies. A mocking framework is a library that provides the ability to replace some components in your system with mock objects and make assertions about how they have been used. Go comes with built-in support for mocking: if you embed an interface in your struct, you can override it at will in your tests. Some great Go mocking libraries are testify - common assertions and mocks that plays nicely; go-sqlmock - Sql mock driver for golang to test database interactions; mockery - A mock code autogenerator for Golang.

testifyby stretchr

Go doticonstar image 19888 doticonVersion:v1.8.4doticon
License: Permissive (MIT)

A toolkit with common assertions and mocks that plays nicely with the standard library

Support
    Quality
      Security
        License
          Reuse

            testifyby stretchr

            Go doticon star image 19888 doticonVersion:v1.8.4doticon License: Permissive (MIT)

            A toolkit with common assertions and mocks that plays nicely with the standard library
            Support
              Quality
                Security
                  License
                    Reuse

                      go-sqlmockby DATA-DOG

                      Go doticonstar image 5282 doticonVersion:v1.5.0doticon
                      License: Others (Non-SPDX)

                      Sql mock driver for golang to test database interactions

                      Support
                        Quality
                          Security
                            License
                              Reuse

                                go-sqlmockby DATA-DOG

                                Go doticon star image 5282 doticonVersion:v1.5.0doticon License: Others (Non-SPDX)

                                Sql mock driver for golang to test database interactions
                                Support
                                  Quality
                                    Security
                                      License
                                        Reuse

                                          mockeryby vektra

                                          Go doticonstar image 4719 doticonVersion:v2.30.1doticon
                                          License: Permissive (BSD-3-Clause)

                                          A mock code autogenerator for Golang

                                          Support
                                            Quality
                                              Security
                                                License
                                                  Reuse

                                                    mockeryby vektra

                                                    Go doticon star image 4719 doticonVersion:v2.30.1doticon License: Permissive (BSD-3-Clause)

                                                    A mock code autogenerator for Golang
                                                    Support
                                                      Quality
                                                        Security
                                                          License
                                                            Reuse

                                                              gockby h2non

                                                              Go doticonstar image 1873 doticonVersion:v1.2.0doticon
                                                              License: Permissive (MIT)

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

                                                              Support
                                                                Quality
                                                                  Security
                                                                    License
                                                                      Reuse

                                                                        gockby h2non

                                                                        Go doticon star image 1873 doticonVersion:v1.2.0doticon License: Permissive (MIT)

                                                                        HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
                                                                        Support
                                                                          Quality
                                                                            Security
                                                                              License
                                                                                Reuse

                                                                                  httpmockby jarcoal

                                                                                  Go doticonstar image 1678 doticonVersion:v1.3.0doticon
                                                                                  License: Permissive (MIT)

                                                                                  HTTP mocking for Golang

                                                                                  Support
                                                                                    Quality
                                                                                      Security
                                                                                        License
                                                                                          Reuse

                                                                                            httpmockby jarcoal

                                                                                            Go doticon star image 1678 doticonVersion:v1.3.0doticon License: Permissive (MIT)

                                                                                            HTTP mocking for Golang
                                                                                            Support
                                                                                              Quality
                                                                                                Security
                                                                                                  License
                                                                                                    Reuse

                                                                                                      moqby matryer

                                                                                                      Go doticonstar image 1559 doticonVersion:v0.3.1doticon
                                                                                                      License: Permissive (MIT)

                                                                                                      Interface mocking tool for go generate

                                                                                                      Support
                                                                                                        Quality
                                                                                                          Security
                                                                                                            License
                                                                                                              Reuse

                                                                                                                moqby matryer

                                                                                                                Go doticon star image 1559 doticonVersion:v0.3.1doticon License: Permissive (MIT)

                                                                                                                Interface mocking tool for go generate
                                                                                                                Support
                                                                                                                  Quality
                                                                                                                    Security
                                                                                                                      License
                                                                                                                        Reuse

                                                                                                                          httpliveby gencebay

                                                                                                                          Go doticonstar image 1123 doticonVersion:20201202124733-201502adoticon
                                                                                                                          License: Permissive (MIT)

                                                                                                                          HTTP Request & Response Service, Mock HTTP

                                                                                                                          Support
                                                                                                                            Quality
                                                                                                                              Security
                                                                                                                                License
                                                                                                                                  Reuse

                                                                                                                                    httpliveby gencebay

                                                                                                                                    Go doticon star image 1123 doticonVersion:20201202124733-201502adoticon License: Permissive (MIT)

                                                                                                                                    HTTP Request & Response Service, Mock HTTP
                                                                                                                                    Support
                                                                                                                                      Quality
                                                                                                                                        Security
                                                                                                                                          License
                                                                                                                                            Reuse

                                                                                                                                              stripe-mockby stripe

                                                                                                                                              Go doticonstar image 1190 doticonVersion:v0.164.0doticon
                                                                                                                                              License: Permissive (MIT)

                                                                                                                                              stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's testmode to make test suites integrating with Stripe faster and less brittle.

                                                                                                                                              Support
                                                                                                                                                Quality
                                                                                                                                                  Security
                                                                                                                                                    License
                                                                                                                                                      Reuse

                                                                                                                                                        stripe-mockby stripe

                                                                                                                                                        Go doticon star image 1190 doticonVersion:v0.164.0doticon License: Permissive (MIT)

                                                                                                                                                        stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's testmode to make test suites integrating with Stripe faster and less brittle.
                                                                                                                                                        Support
                                                                                                                                                          Quality
                                                                                                                                                            Security
                                                                                                                                                              License
                                                                                                                                                                Reuse

                                                                                                                                                                  gnomockby orlangure

                                                                                                                                                                  Go doticonstar image 1188 doticonVersion:v0.28.0doticon
                                                                                                                                                                  License: Permissive (MIT)

                                                                                                                                                                  Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻

                                                                                                                                                                  Support
                                                                                                                                                                    Quality
                                                                                                                                                                      Security
                                                                                                                                                                        License
                                                                                                                                                                          Reuse

                                                                                                                                                                            gnomockby orlangure

                                                                                                                                                                            Go doticon star image 1188 doticonVersion:v0.28.0doticon License: Permissive (MIT)

                                                                                                                                                                            Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻
                                                                                                                                                                            Support
                                                                                                                                                                              Quality
                                                                                                                                                                                Security
                                                                                                                                                                                  License
                                                                                                                                                                                    Reuse

                                                                                                                                                                                      mmockby jmartin82

                                                                                                                                                                                      Go doticonstar image 641 doticonVersion:v3.1.6doticon
                                                                                                                                                                                      License: Permissive (MIT)

                                                                                                                                                                                      Mmock is an HTTP mocking application for testing and fast prototyping

                                                                                                                                                                                      Support
                                                                                                                                                                                        Quality
                                                                                                                                                                                          Security
                                                                                                                                                                                            License
                                                                                                                                                                                              Reuse

                                                                                                                                                                                                mmockby jmartin82

                                                                                                                                                                                                Go doticon star image 641 doticonVersion:v3.1.6doticon License: Permissive (MIT)

                                                                                                                                                                                                Mmock is an HTTP mocking application for testing and fast prototyping
                                                                                                                                                                                                Support
                                                                                                                                                                                                  Quality
                                                                                                                                                                                                    Security
                                                                                                                                                                                                      License
                                                                                                                                                                                                        Reuse

                                                                                                                                                                                                          apisproutby danielgtaylor

                                                                                                                                                                                                          Go doticonstar image 627 doticonVersion:v1.3.0doticon
                                                                                                                                                                                                          License: Permissive (MIT)

                                                                                                                                                                                                          Lightweight, blazing fast, cross-platform OpenAPI 3 mock server with validation

                                                                                                                                                                                                          Support
                                                                                                                                                                                                            Quality
                                                                                                                                                                                                              Security
                                                                                                                                                                                                                License
                                                                                                                                                                                                                  Reuse

                                                                                                                                                                                                                    apisproutby danielgtaylor

                                                                                                                                                                                                                    Go doticon star image 627 doticonVersion:v1.3.0doticon License: Permissive (MIT)

                                                                                                                                                                                                                    Lightweight, blazing fast, cross-platform OpenAPI 3 mock server with validation
                                                                                                                                                                                                                    Support
                                                                                                                                                                                                                      Quality
                                                                                                                                                                                                                        Security
                                                                                                                                                                                                                          License
                                                                                                                                                                                                                            Reuse

                                                                                                                                                                                                                              clockby benbjohnson

                                                                                                                                                                                                                              Go doticonstar image 639 doticonVersion:v1.3.0doticon
                                                                                                                                                                                                                              License: Permissive (MIT)

                                                                                                                                                                                                                              Clock is a small library for mocking time in Go.

                                                                                                                                                                                                                              Support
                                                                                                                                                                                                                                Quality
                                                                                                                                                                                                                                  Security
                                                                                                                                                                                                                                    License
                                                                                                                                                                                                                                      Reuse

                                                                                                                                                                                                                                        clockby benbjohnson

                                                                                                                                                                                                                                        Go doticon star image 639 doticonVersion:v1.3.0doticon License: Permissive (MIT)

                                                                                                                                                                                                                                        Clock is a small library for mocking time in Go.
                                                                                                                                                                                                                                        Support
                                                                                                                                                                                                                                          Quality
                                                                                                                                                                                                                                            Security
                                                                                                                                                                                                                                              License
                                                                                                                                                                                                                                                Reuse

                                                                                                                                                                                                                                                  gripmockby tokopedia

                                                                                                                                                                                                                                                  Go doticonstar image 536 doticonVersion:v1.12.1-betadoticon
                                                                                                                                                                                                                                                  License: Permissive (Apache-2.0)

                                                                                                                                                                                                                                                  gRPC Mock Server

                                                                                                                                                                                                                                                  Support
                                                                                                                                                                                                                                                    Quality
                                                                                                                                                                                                                                                      Security
                                                                                                                                                                                                                                                        License
                                                                                                                                                                                                                                                          Reuse

                                                                                                                                                                                                                                                            gripmockby tokopedia

                                                                                                                                                                                                                                                            Go doticon star image 536 doticonVersion:v1.12.1-betadoticon License: Permissive (Apache-2.0)

                                                                                                                                                                                                                                                            gRPC Mock Server
                                                                                                                                                                                                                                                            Support
                                                                                                                                                                                                                                                              Quality
                                                                                                                                                                                                                                                                Security
                                                                                                                                                                                                                                                                  License
                                                                                                                                                                                                                                                                    Reuse

                                                                                                                                                                                                                                                                      killgraveby friendsofgo

                                                                                                                                                                                                                                                                      Go doticonstar image 388 doticonVersion:v0.4.1doticon
                                                                                                                                                                                                                                                                      License: Permissive (MIT)

                                                                                                                                                                                                                                                                      Simple way to generate mock servers written in Go

                                                                                                                                                                                                                                                                      Support
                                                                                                                                                                                                                                                                        Quality
                                                                                                                                                                                                                                                                          Security
                                                                                                                                                                                                                                                                            License
                                                                                                                                                                                                                                                                              Reuse

                                                                                                                                                                                                                                                                                killgraveby friendsofgo

                                                                                                                                                                                                                                                                                Go doticon star image 388 doticonVersion:v0.4.1doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                                                Simple way to generate mock servers written in Go
                                                                                                                                                                                                                                                                                Support
                                                                                                                                                                                                                                                                                  Quality
                                                                                                                                                                                                                                                                                    Security
                                                                                                                                                                                                                                                                                      License
                                                                                                                                                                                                                                                                                        Reuse

                                                                                                                                                                                                                                                                                          openapi-mockby muonsoft

                                                                                                                                                                                                                                                                                          Go doticonstar image 367 doticonVersion:v0.3.9doticon
                                                                                                                                                                                                                                                                                          License: Permissive (MIT)

                                                                                                                                                                                                                                                                                          OpenAPI mock server with random data generation

                                                                                                                                                                                                                                                                                          Support
                                                                                                                                                                                                                                                                                            Quality
                                                                                                                                                                                                                                                                                              Security
                                                                                                                                                                                                                                                                                                License
                                                                                                                                                                                                                                                                                                  Reuse

                                                                                                                                                                                                                                                                                                    openapi-mockby muonsoft

                                                                                                                                                                                                                                                                                                    Go doticon star image 367 doticonVersion:v0.3.9doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                                                                    OpenAPI mock server with random data generation
                                                                                                                                                                                                                                                                                                    Support
                                                                                                                                                                                                                                                                                                      Quality
                                                                                                                                                                                                                                                                                                        Security
                                                                                                                                                                                                                                                                                                          License
                                                                                                                                                                                                                                                                                                            Reuse

                                                                                                                                                                                                                                                                                                              mock-databy faisaltheparttimecoder

                                                                                                                                                                                                                                                                                                              Go doticonstar image 107 doticonVersion:v3.0doticon
                                                                                                                                                                                                                                                                                                              License: Permissive (MIT)

                                                                                                                                                                                                                                                                                                              Mock data in PostgreSQL/Greenplum databases

                                                                                                                                                                                                                                                                                                              Support
                                                                                                                                                                                                                                                                                                                Quality
                                                                                                                                                                                                                                                                                                                  Security
                                                                                                                                                                                                                                                                                                                    License
                                                                                                                                                                                                                                                                                                                      Reuse

                                                                                                                                                                                                                                                                                                                        mock-databy faisaltheparttimecoder

                                                                                                                                                                                                                                                                                                                        Go doticon star image 107 doticonVersion:v3.0doticon License: Permissive (MIT)

                                                                                                                                                                                                                                                                                                                        Mock data in PostgreSQL/Greenplum databases
                                                                                                                                                                                                                                                                                                                        Support
                                                                                                                                                                                                                                                                                                                          Quality
                                                                                                                                                                                                                                                                                                                            Security
                                                                                                                                                                                                                                                                                                                              License
                                                                                                                                                                                                                                                                                                                                Reuse

                                                                                                                                                                                                                                                                                                                                  See similar Kits and Libraries