https://github.com/ovechkin-dm/mockio
Mockito for golang
https://github.com/ovechkin-dm/mockio
go golang mock mocking mockito testing testing-tools unit-testing
Last synced: 5 months ago
JSON representation
Mockito for golang
- Host: GitHub
- URL: https://github.com/ovechkin-dm/mockio
- Owner: ovechkin-dm
- License: mit
- Created: 2023-03-31T11:25:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-03T14:40:23.000Z (8 months ago)
- Last Synced: 2025-11-03T16:20:58.790Z (8 months ago)
- Topics: go, golang, mock, mocking, mockito, testing, testing-tools, unit-testing
- Language: Go
- Homepage:
- Size: 3.09 MB
- Stars: 187
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Mockio
[](https://github.com/ovechkin-dm/mockio/actions)
[](https://app.codecov.io/gh/ovechkin-dm/mockio)
[](https://goreportcard.com/report/github.com/ovechkin-dm/mockio)
[](https://pkg.go.dev/github.com/ovechkin-dm/mockio)
[](https://github.com/ovechkin-dm/mockio/releases)
[](https://github.com/ovechkin-dm/mockio/blob/main/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](https://ovechkin-dm.github.io/mockio/latest/)
# Quick start
Install latest version of the library using go get command:
```bash
go get -u github.com/ovechkin-dm/mockio/v2
```
Create a simple mock and test:
```go
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()
}
}
```