Skip to content

ovechkin-dm/mockio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8eec957 · May 1, 2025
Apr 12, 2025
Jun 12, 2024
Apr 17, 2025
Apr 30, 2025
Apr 30, 2025
Apr 12, 2025
May 1, 2025
May 1, 2025
May 1, 2025
Feb 26, 2024
Aug 28, 2024
Apr 7, 2025
May 1, 2025
Mar 31, 2023
May 1, 2025
Apr 17, 2025
Apr 30, 2025
Apr 30, 2025
Sep 10, 2024

Repository files navigation

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()
    }
}