monkey VS gomock

Compare monkey vs gomock and see what are their differences.

monkey

Monkey patching in Go (by bouk)

gomock

GoMock is a mocking framework for the Go programming language. (by golang)
Our great sponsors
  • Nanos - Run Linux Software Faster and Safer than Linux with Unikernels
  • Scout APM - A developer's best friend. Try free for 14-days
  • SaaSHub - Software Alternatives and Reviews
monkey gomock
8 15
2,370 6,297
- 2.9%
0.0 6.9
over 1 year ago 9 days ago
Go Go
GNU General Public License v3.0 or later Apache License 2.0
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.

monkey

Posts with mentions or reviews of monkey. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2021-10-16.
  • is there an easy (python like way) to do mocks?
    reddit.com/r/golang | 2021-10-16
    I discovered this lib a few days ago. https://github.com/bouk/monkey it allows you to monkey patch entire functions, replacing them by whatever you want. Perfect for mocking. It's simple to use. The program is hard patching the code using assembly to replace the function address at runtime. You should not use this lib out of your tests since it's absolutely not safe. It's only compatible with linux and windows. But it works great!
  • Oops!
  • Monkey Patching in Go (2015)
    news.ycombinator.com | 2021-08-22
  • I do not give anyone permissions to use this tool for any purpose. Don’t use it. I’m not interested in changing this license. Please don’t ask.
  • Project includes a dependancy that has a license that forbids its use
    news.ycombinator.com | 2021-08-22
    From the explaining blog post [0]

    > If you’re not interested in how it works and you just want to do monkey patching, then you can find the library here.

    Also

    > Wrapping it up in a nice library

    > I took the above code and put it in an easy to use library. It supports 32 bit, reversing patches, and patching instance methods. I wrote a couple of examples and put those in the README.

    Then in the README[1]:

    > Make sure you read the notes at the bottom of the README if you intend to use this library.

    Either the author is confused or has decided that he doesn't want to maintain an hack. Anyway license is pretty clear.

    There was an HN thread[2] when it was released.

    [0] https://bou.ke/blog/monkey-patching-in-go/

    [1] https://github.com/bouk/monkey

    [2] https://news.ycombinator.com/item?id=9290917

    news.ycombinator.com | 2021-08-22
    "This is as unsafe as it sounds and I don't recommend anyone do it outside of a testing environment."

    [1]: https://github.com/bouk/monkey#i-thought-that-monkeypatching...

  • is Test_xxx func safe to access shared data?
    reddit.com/r/golang | 2021-06-25
    WRT monkeypatch, again, this is a "global" thing and assuming you are talking about bouk's monkeypatch library the author makes the note that
  • Go partial mocks?
    reddit.com/r/golang | 2021-05-10
    For example: https://github.com/bouk/monkey

gomock

Posts with mentions or reviews of gomock. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2021-10-23.
  • What mocking framework do you prefer?
    reddit.com/r/golang | 2021-10-23
    Gomock or mockery?
    reddit.com/r/golang | 2021-10-23
    I used to use Mockery, but it was unmaintained for a long time, and not that great, so these days it's Mock, which is nicer in several ways.
  • Mocking with High-Order Functions in Go
    reddit.com/r/golang | 2021-08-06
    Honestly curious - why wouldn't you use something like https://github.com/golang/mock to generate your mocks from an interface. Way more productive, consistent and cleaner. Spend more time and focus on your business logic rather than something that's already been solved.
  • Constructors: how to keep compatibility in a public API?
    reddit.com/r/golang | 2021-08-03
    Sorry for badly explaining. Issue explaining it better than me: https://github.com/golang/mock/issues/324
  • What are the most useful packages you know for Go?
    reddit.com/r/golang | 2021-07-25
    https://github.com/golang/mock - Auto generate mocks from interfaces for unit testing
  • Flexible mocking for testing in Go (without using a framework)
    reddit.com/r/golang | 2021-07-20
    BTW https://github.com/golang/mock is way more propular and does similar things.
  • My experience trying TDD for the first time in Go
    dev.to | 2021-05-27
    The first day, I wrote my tests for some GET routes. We use something called go-mock in our unit tests, which allows you to only focus on testing the function you're writing. Because of this, I found that you still needed to have a good idea of the code you want to write while writing out the tests. In our case, we needed to mock out our calls to an external API. If you asked for my opinion after the first day, I would've told you that I could envision the benefits of TDD for something like end to end testing, where it's a black box and you're only verifying that the output is what's expected from a given input. But for unit testing, it wasn't any different than just writing the code first.
  • Goreen tea : golang boilerplate for data-intensive microservice
    dev.to | 2021-05-11
    Unit testing with go-mock
  • Debugging Go Microservices in Kubernetes with VScode
    dev.to | 2021-04-09
    Sure, you can use unit tests with tools like GoMock and GoStub to simulate external dependencies or introduce synthetic data into the mix, but it still leaves you unsure if it will work with data from your actual services.
  • Part-2: Building a basic microservice with unidirectional-streaming gRPC using Golang
    dev.to | 2021-02-25
    To write the unit test we'll need to generate the mock of multiple interface as required. mockgen is the ready-to-go framework for mocking in Golang, so we'll be leveraging it in our unit tests.

What are some alternatives?

When comparing monkey and gomock you can also consider the following projects:

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

go-sqlmock - Sql mock driver for golang to test database interactions

sqlx - general purpose extensions to golang's database/sql

minimock - Powerful mock generation tool for Go programming language

zerolog - Zero Allocation JSON Logger

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

realize - Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

pgx - PostgreSQL driver and toolkit for Go

gotests - Automatically generate Go test boilerplate from your source code.

Mmock - Mmock is an HTTP mocking application for testing and fast prototyping

hoverfly - Lightweight service virtualization/API simulation tool for developers and testers