How do you control behaviour in mocked interface ?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/golang

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • SaaSHub - Software Alternatives and Reviews
  • moq

    Interface mocking tool for go generate

    I like the way of matryer/moq a lot. Basically, it generates a func for each of the methods of an interface, therefore the behaviour is clear to everyone without too much abstraction.

  • minimock

    Powerful mock generation tool for Go programming language

    In our company projects we use https://github.com/gojuno/minimock for units

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • counterfeiter

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

    Another alternative to use would be counterfeiter, it generates a type from your interface that could be used as a mock, stub or spy. I wrote a short post covering that tool if you're interested.

  • mockery

    A mock code autogenerator for Golang (by vektra)

    I use mockery to generate mocks based on my interfaces: https://github.com/vektra/mockery

  • Testify

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

    I’m a fan of https://github.com/stretchr/testify

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts