SaaSHub helps you find the best software and product alternatives Learn more →
Top 23 Go Mock Projects
-
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.
-
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.
-
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 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.
-
Mocking the http client with explicit responses; for example using h2non/gock
-
-
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-26Repo for reference: https://github.com/irahardianto/service-pattern-go
-
-
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.
-
This is meant to work a little like wiremock for grpc https://github.com/tokopedia/gripmock
-
-
-
-
I used also other lib to mock different components like redis cache.
-
-
-
go-smtp-mock
SMTP mock server written on Golang. Mimic any 📤 SMTP server behavior for your test environment with fake SMTP server.
-
-
-
-
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-17tonic -- tonic lets you write simpler gin handlers
-
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
Go Mock related posts
- Review: 10 Top API Mock Tools
- Golang rest-api testing
- Is this a good way to make sure that a mocked function is called inside the Unit Test?
- Testing calls to external APIs
- GitHub is the trap that Microsoft if using to secretly and illegally read your code with total disrespect to its license, in order to train its AI to write better code and, eventually, make you redundant. Change my mind
- What happens when a plugin/VST is no longer supported?
- Comprehensive Guide to Testing in Go
-
A note from our sponsor - #<SponsorshipServiceOld:0x00007fea596a1940>
www.saashub.com | 28 Jan 2023
Index
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 |