Go Mock

Open-source Go projects categorized as Mock

Top 23 Go Mock Projects

  • gomock

    GoMock is a mocking framework for the Go programming language. (by golang)

    Project mention: Go API Project Set-Up | dev.to | 2022-12-23

    Unit tests are leveraged to test individual units of code. As such it is not recommended for a developer to scaffold entire dependencies for the sake of testing a single object. Due to the way Go's specific implementations work, I've learned over time to declare interfaces for a lot of the structs that I use in Go. Interfaces not only define a contract for which struct-based implementations should adhere, but they also provide a mechanism for which struct methods can be mocked. While I've experimented with the mock package in testify, I've come to prefer the mock functionality which is provided by mockgen.

  • go-sqlmock

    Sql mock driver for golang to test database interactions

    Project mention: Creating an API using Go and sqlc | dev.to | 2022-10-24

    For that, I used the lib go-sqlmock. So, for example, the following snippet is part of the person/service_test.go file:

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

  • mockery

    A mock code autogenerator for Golang (by vektra)

    Project mention: How do you write/generate mocks for testing? | reddit.com/r/golang | 2022-09-21

    My bread and butter is mockery (https://github.com/vektra/mockery). It has a few shortcomings (a config would be really nice in my project) which should be fixed in v3 (https://github.com/vektra/mockery#v3).

  • hoverfly

    Lightweight service virtualization/API simulation tool for developers and testers

    Project mention: Review: 10 Top API Mock Tools | dev.to | 2022-12-27

    Hoverfly is an open-source tool for mocking and simulating APIs. It is relatively easy to use and has a wide range of features for mocking and simulating APIs, including support for importing and exporting mock configurations, generating random data for responses, and setting up conditional responses based on the contents of incoming requests.

  • gock

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

    Project mention: Testing calls to external APIs | reddit.com/r/golang | 2022-12-09

    Mocking the http client with explicit responses; for example using h2non/gock

  • httpmock

    HTTP mocking for Golang

    Project mention: Golang rest-api testing | reddit.com/r/golang | 2022-12-27
  • counterfeiter

    A tool for generating self-contained, type-safe test doubles in go

    Project mention: Is this a good way to make sure that a mocked function is called inside the Unit Test? | reddit.com/r/golang | 2022-12-24

    Yes, that's a good way to do that; there are a lot of packages that allow you to mock and spy the calls if you're looking for one that generates the code for you I can recommend counterfeiter, I also have a short blog that covers it.

  • InfluxDB

    Build time-series-based applications quickly and at scale.. InfluxDB is the Time Series Platform where developers build real-time applications for analytics, IoT and cloud-native services. Easy to start, it is available in the cloud or on-premises.

  • service-pattern-go

    Simple clean Go REST API architecture with dependency injection and mocking example, following SOLID principles.

    Project mention: Question about the service pattern and data racing in Go | reddit.com/r/golang | 2022-05-26

    Repo for reference: https://github.com/irahardianto/service-pattern-go

  • Mmock

    Mmock is an HTTP mocking application for testing and fast prototyping

  • go-txdb

    Immutable transaction isolated sql driver for golang

    Project mention: Unit Testing a Grom Application With a Real DB Server | reddit.com/r/golang | 2022-07-27

    The first one is TestMain, which could improve the lifecycle management of the container. The second one is DATA-DOG/go-txdb, this allows you to open a new db connection running in a transaction, so each test could have its own isolated DB connection.

  • gripmock

    gRPC Mock Server

    Project mention: Mock a server to service a grpc call in python | reddit.com/r/grpc | 2022-10-26

    This is meant to work a little like wiremock for grpc https://github.com/tokopedia/gripmock

  • minimock

    Powerful mock generation tool for Go programming language

    Project mention: How do you write/generate mocks for testing? | reddit.com/r/golang | 2022-09-21
  • killgrave

    Simple way to generate mock servers written in Go

  • openapi-mock

    OpenAPI mock server with random data generation

  • redismock

    Redis client Mock

    Project mention: how to mock DBs | reddit.com/r/golang | 2022-05-30

    I used also other lib to mock different components like redis cache.

  • govcr

    HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing

  • gomockhandler

    Mr. gomockhandler is the clever and more agile manager of golang/mock 👔

  • go-smtp-mock

    SMTP mock server written on Golang. Mimic any 📤 SMTP server behavior for your test environment with fake SMTP server.

  • timex

    A test-friendly replacement for golang's time package (by cabify)

  • go-localstack

    Go Wrapper for using localstack

  • go-github-mock

    A library to aid unittesting code that uses Golang's Github SDK

  • gadgeto

    Gadgeto! is a collection of tools that aim to facilitate the development of REST APIs in Go.

    Project mention: Is OpenAPI 3.x+ the right path for me on creating APIs with GoLang? | reddit.com/r/golang | 2022-11-17

    tonic -- tonic lets you write simpler gin handlers

  • mockc

    Completely type-safe compile-time mock generator for Go

  • SaaSHub

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

NOTE: The open source projects on this list are ordered by number of github stars. The number of mentions indicates repo mentiontions in the last 12 Months or since we started tracking (Dec 2020). The latest post mention was on 2022-12-27.

Go Mock related posts


What are some of the best open-source Mock projects in Go? This list will help you:

Project Stars
1 gomock 8,446
2 go-sqlmock 4,963
3 mockery 4,266
4 hoverfly 1,958
5 gock 1,782
6 httpmock 1,575
7 counterfeiter 777
8 service-pattern-go 685
9 Mmock 627
10 go-txdb 504
11 gripmock 503
12 minimock 476
13 killgrave 364
14 openapi-mock 350
15 redismock 158
16 govcr 141
17 gomockhandler 81
18 go-smtp-mock 67
19 timex 66
20 go-localstack 62
21 go-github-mock 58
22 gadgeto 39
23 mockc 30
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives