Go MIT

mockio

Mockito for golang

O

ovechkin-dm

Dernière activité 29 juil. 2026
ovechkin-dm/mockio

196

étoiles

7

forks

0

issues ouvertes

gogolangmockmockingmockitotestingtesting-toolsunit-testing

Ce README est souvent en anglais.

Mockio

Build Status Codecov Go Report Card Documentation Release License

Mock library for golang without code generation

Mockio is a Golang library that provides functionality for mocking and stubbing functions and methods in tests inspired by mockito. The library is designed to simplify the testing process by allowing developers to easily create test doubles for their code, which can then be used to simulate different scenarios.

Documentation

Latest documentation is available here

Quick start

Install latest version of the library using go get command:

go get -u github.com/ovechkin-dm/mockio/v2

Create a simple mock and test:

package main

import (
    . "github.com/ovechkin-dm/mockio/v2/mock"
    "testing"
)

type Greeter interface {
    Greet(name string) string
}

func TestGreet(t *testing.T) {
    ctrl := NewMockController(t)
    m := Mock[Greeter](ctrl)
    WhenSingle(m.Greet("John")).ThenReturn("Hello, John!")
    if m.Greet("John") != "Hello, John!" {
        t.Fail()
    }
}

Projets similaires

GoMock is a mocking framework for the Go programming language.

Go
Uuber-go
3,4 k étoiles179

A mock code autogenerator for Go

Gogenerationgeneratorgo
Vvektra
7,2 k étoiles459

Interface mocking tool for go generate

Gocodegengolangmocking
Mmatryer
2,2 k étoiles136