ovechkin-dm/mockio

Mockito for golang

Go

196

57 commits

updated Jul 29, 2026

See the code

README

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()
    }
}
go
golang
mock
mocking
mockito
testing
testing-tools
unit-testing

ovechkin-dm/mockio

Mockito for golang

Go

196

57 commits

updated Jul 29, 2026

See the code

README

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()
    }
}
go
golang
mock
mocking
mockito
testing
testing-tools
unit-testing

Project health

Overall

3.7/10

Maintained

0/10

Code review

1/10
OpenSSF Scorecard

Latest release

v1.0.2 · Oct 28, 2024

Releases this year

0

Significant stargazers

Masaaki Goshima

841 followers · starred Apr 2025

Kei Kamikawa

424 followers · starred Apr 2025

KADOTA, Kyohei

103 followers · starred Mar 2025

Ben Boyter

748 followers · starred Nov 2023