- Home
- gRPC Tools
- grpcmock-go
grpcmock-go
What it is
grpcmock-go is a free Go module for testing gRPC clients and servers. It includes utilities for setting up server mocks with expectations for methods, headers, and payloads, plus helpers that invoke gRPC methods from tests. The examples cover unary, client-streaming, server-streaming, and bidirectional-streaming calls. Request matching can use exact values, regular expressions, JSON, or custom matchers. Mock responses can return payloads or errors, or use custom handlers; streaming client calls can also use custom handlers. Services can be registered from generated Go code, as service instances, or by method when generated code is not available. The project recommends MockServerWithBufConn for testing an application against a mocked server, and examples use in-memory bufconn listeners and context dialers. Installation uses `go get go.nhat.io/grpcmock`. The listed requirement is Go 1.25 or later. The repository identifies its license as MIT and is published under the nhatthm account. Its listed Open-source Go module plan costs nothing.
For and against
For
- Supports unary and three streaming method types
- Provides exact, regex, JSON, and custom matchers
- Can register services without generated Go code
- MIT-licensed and listed as free
Against
- Requires Go 1.25 or later
- The listed platforms are Linux and self-hosted
The verdict
grpcmock-go provides test utilities for both sides of gRPC calls, including streaming and in-memory server testing. Check the Go version requirement before using it.
Who it suits
It suits Go developers writing tests for gRPC clients, servers, and streaming methods. The listed Go prerequisite is version 1.25 or later.
Plans and prices
Open-source Go module
gRPC testing utilities for Go
Read 5 Oct 2026 · github.com
On the record
- Client calls
- It provides helpers to invoke gRPC methods from tests.github.com · read 5 Oct 2026
- Custom handlers
- Streaming client invocations can use custom handlers.github.com · read 5 Oct 2026
- Donation
- The README invites users to buy the maintainer a coffee if the project saved development time.github.com · read 5 Oct 2026
- Funding
- The README invites users who saved development time to buy the maker a cup of coffee.github.com · read 4 Oct 2026
- In-memory connections
- Examples use gRPC bufconn listeners and context dialers for test connections.github.com · read 5 Oct 2026
- In-memory testing
- The server guide recommends MockServerWithBufConn for testing an application with a mocked gRPC server.github.com · read 4 Oct 2026
- Install
- The README gives `go get go.nhat.io/grpcmock` as the installation command.github.com · read 5 Oct 2026
- Installation
- The README gives `go get go.nhat.io/grpcmock` as the installation command.github.com · read 4 Oct 2026
- License
- The repository identifies its license as MIT.github.com · read 5 Oct 2026
- Maintainer
- The repository is published under the GitHub account nhatthm.github.com · read 5 Oct 2026
- Mock responses
- The server guide says mocks can return errors, payloads, or use custom handlers.github.com · read 4 Oct 2026
- Prerequisite
- The README lists Go 1.25 or later as a prerequisite.github.com · read 4 Oct 2026
- Purpose
- grpcmock is a set of gRPC test utilities for Golang.github.com · read 5 Oct 2026
- Release
- GitHub lists v0.34.0, released December 12, 2025, as the latest release.github.com · read 5 Oct 2026
- Request matching
- The server guide documents exact, regular-expression, JSON, and custom matchers for matching values.github.com · read 4 Oct 2026
- Requirement
- The repository README lists Go 1.25 or later as a prerequisite.github.com · read 5 Oct 2026
- Server and client testing
- The README shows utilities for mocking gRPC servers and invoking gRPC methods from tests.github.com · read 4 Oct 2026
- Server mocks
- It lets tests mock a gRPC server and configure expectations for methods, headers, and payloads.github.com · read 5 Oct 2026