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.
Latest documentation is available here
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()
}
}
Overall
Maintained
Code review
Go module
Latest release
Releases this year
841 followers · starred Apr 2025
424 followers · starred Apr 2025
103 followers · starred Mar 2025
748 followers · starred Nov 2023
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.
Latest documentation is available here
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()
}
}
Overall
Maintained
Code review
Go module
Latest release
Releases this year
841 followers · starred Apr 2025
424 followers · starred Apr 2025
103 followers · starred Mar 2025
748 followers · starred Nov 2023