How do you control behaviour in mocked interface ?

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

Our great sponsors
  • Mergify - Tired of breaking your main and manually rebasing outdated pull requests?
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • SonarQube - Static code analysis for 29 languages.
  • moq

    Interface mocking tool for go generate (by matryer)

    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

  • Mergify

    Tired of breaking your main and manually rebasing outdated pull requests?. Managing outdated pull requests is time-consuming. Mergify's Merge Queue automates your pull request management & merging. It's fully integrated to GitHub & coordinated with any CI. Start focusing on code. Try Mergify for free.

  • 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 Go (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

  • InfluxDB

    Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.

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