mockery
A mock code autogenerator for Go (by vektra)
gock
HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽ (by h2non)
mockery | gock | |
---|---|---|
20 | 10 | |
6,011 | 2,088 | |
1.3% | - | |
8.1 | 3.5 | |
5 days ago | 13 days ago | |
Go | Go | |
BSD 3-clause "New" or "Revised" License | MIT License |
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
mockery
Posts with mentions or reviews of mockery.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2023-08-26.
-
I Write Tests in Go
I'm far too lazy to write mocks by hand in go. You can generate a mock for a given interface with mockery https://github.com/vektra/mockery
-
go-ecommerce-microservices: A practical e-commerce microservices, built with cqrs, event sourcing, vertical slice architecture, event-driven architecture.
Some of the features: - ✅ Using Vertical Slice Architecture as a high level architecture - ✅ Using Event Driven Architecture on top of RabbitMQ Message Broker with a custom [Event Bus](pkg/messaging/bus/) - ✅ Using Event Sourcing in Audit Based services like [Orders Service](services/orders/) - ✅ Using CQRS Pattern and Mediator Patternon top of Go-MediatR library - ✅ Using Dependency Injection and Inversion of Controlon top of uber-go/fx library - ✅ Using RESTFul api with Echo framework and using swagger with swaggo/swag library - ✅ Using Postgres and EventStoreDB to write databases with fully supports transactions(ACID) - ✅ Using MongoDB and Elastic Search for read databases (NOSQL) - ✅ Using OpenTelemetry for collection Distributed Tracing with using Jaeger and Zipkin - ✅ Using OpenTelemetry for collection Metrics with using Prometheus and Grafana - ✅ Using Unit Test for testing small units with mocking dependent classes and using Mockery for mocking dependencies - ✅ Using End2End Test and Integration Test for testing features with all of their real dependeinces using docker containers (cleanup tests) and testcontainers-go library
- Direction of mockery: absorb different styles of mocks into this project · vektra mockery · Discussion #671
-
Go: Write Mock Test cases using Mockery and
Read mockery documentation: https://vektra.github.io/mockery/
-
Mocking unexported interfaces?
https://github.com/vektra/mockery is the better mocking framework in my biased opinion. The Google maintainers for gomock seem to have neglected the project.
-
I want to contribute to open source but don't know where to start
There are some one liner changes you can implement in https://github.com/vektra/mockery
-
Is gomock still maintained and recommended?
When there's just one heavyweight dependency you're interacting with, perhaps a one-off stub/fake is simpler, but I would posit that auto-generated mocks via things like mockery + go:generate leave less test code to maintain vs. perhaps many stubs across the project.
-
vektra/mockery: v2.21.0 includes "packages" config section, allowing 5x faster mock generation and more fine-grained control over mocks
Please take a look at the documentation linked here, and the related discussion topic that spawned this.
-
Issue implementing interface method that returns another interface
As you can see, the package has a chained method Logical().Write() . Since I want to create tests for PublicFunctionIWantToTest, I want to pass down all the functionality as interface so that I can use https://vektra.github.io/mockery/ to create mocks for it.
- FEEDBACK REQUESTED: Deprecation of automatic interface discovery · Discussion #549 · vektra/mockery
gock
Posts with mentions or reviews of gock.
We have used some of these posts to build our list of alternatives
and similar projects. The last one was on 2022-12-09.
-
Testing calls to external APIs
Mocking the http client with explicit responses; for example using h2non/gock
- What features would you consider missing/nice to haves for backend web development in Rust?
-
Mock HTTP response
Check out gock.
- API Mock Testing Frameworks
-
Testing methods with HTTP calls?
h2non/gock and
-
Go Package for Mocking HTTP Traffic: github.com/h2non/gock
Last time I covered testing in Go I mentioned a package used for testing equality called github.com/google/go-cmp, this time I will share with you a way to mock HTTP traffic using the package github.com/h2non/gock.
-
HTTP mocking
If you need a good library for mocking http servers https://github.com/h2non/gock does a great job.
-
best way to mock/unit test http.Client?
github.com/h2non/gock
- How to mock `jwk.Fetch` in my unit tests?
- Has anyone here compiled DroneCI from scratch?
What are some alternatives?
When comparing mockery and gock you can also consider the following projects:
gomock - GoMock is a mocking framework for the Go programming language.
httpmock - HTTP mocking for Golang
counterfeiter - A tool for generating self-contained, type-safe test doubles in go
go-sqlmock - Sql mock driver for golang to test database interactions
minimock - Powerful mock generation tool for Go programming language
govcr - HTTP mock for Golang: record and replay HTTP/HTTPS interactions for offline testing
hoverfly - Lightweight service virtualization/ API simulation / API mocking tool for developers and testers
httpexpect - End-to-end HTTP and REST API testing for Go.
moq - Interface mocking tool for go generate
go-txdb - Immutable transaction isolated sql driver for golang