grpcmock
grpcmock.org
- Self-hosted
What grpcmock is
grpcmock, also known as gRPC Mock, is a free, open-source Java tool for mocking gRPC service endpoints in integration and unit tests. It runs self-hosted and lets developers define method stubs with a fluent Java API. Stubs can inspect request headers and bodies, while responses can include configurable delays and vary on later invocations. The tool supports unary, server-streaming, client-streaming, and bidirectional-streaming methods. Tests can verify invocation counts, status, headers, and request messages. The grpcmock-spring-boot module connects the mock server with Spring Boot tests. The grpcmock-junit5 module adds JUnit 5 extensions and an in-process server option; its lifecycle support clears mappings after each test and stops the server when the test class ends. In multithreaded setups, static configuration can cause UNIMPLEMENTED errors because configuration uses a ThreadLocal instance. The documentation recommends obtaining a GrpcMock instance when setup and test code run on different threads. GitHub identifies the project under the Apache-2.0 license.
Who it suits
It suits Java developers writing integration or unit tests for gRPC services, especially teams using Spring Boot or JUnit 5.
Good to know, and what to watch
- Fluent Java API for defining gRPC stubs
- Matches request headers and request bodies
- Supports four gRPC streaming patterns
- Verifies calls and invocation details
- Spring Boot and JUnit 5 integrations
- Static configuration may fail in multithreaded tests
- Self-hosted deployment requires local setup
The verdict
grpcmock covers varied gRPC call patterns and detailed verification in Java tests. Its ThreadLocal configuration behavior needs attention when test setup spans threads.
What the maker publishes
- Concurrency limitation
- In multithreaded test setups, static configuration methods can produce UNIMPLEMENTED errors because gRPC Mock uses a ThreadLocal instance. source
- Configuration
- It configures stubs through a fluent Java API and can match request headers and bodies. source
- gRPC methods
- It supports unary, server streaming, client streaming, and bidirectional streaming methods. source
- In-process option
- Spring Boot and JUnit 5 examples show how to run an in-process server for tests. source
- Intended users
- The project describes itself as a tool for Java developers writing integration or unit tests for gRPC services. source
- Invocation verification
- Tests can verify method invocations, including status, headers, requests, and invocation counts. source
- JUnit 5 integration
- The grpcmock-junit5 module provides JUnit 5 extensions, including an in-process server option. source
- JUnit integration
- The grpcmock-junit5 module provides JUnit 5 extensions, including an in-process server option. source
- License
- The project’s GitHub page identifies its license as Apache-2.0. source
- Matching
- Stubs can match request headers and request bodies. source
- Multithreaded tests
- The documentation says static configuration methods use a ThreadLocal instance and recommends accessing a GrpcMock instance when setup and test methods run on different threads. source
- Project status
- The site describes gRPC Mock as open source. source
- Purpose
- gRPC Mock is a gRPC Java testing tool for mocking service endpoints in integration or unit tests. source
- Purpose
- gRPC Mock is a Java testing tool for mocking gRPC service endpoints in integration or unit tests. source
- Response behavior
- Responses can have configurable delays, and later invocations can return different responses. source
- Response behavior
- Individual responses can have configurable delays, and stubs can return different responses on subsequent invocations. source
- Spring Boot integration
- The grpcmock-spring-boot module integrates gRPC Mock with Spring Boot tests. source
- Spring Boot integration
- The grpcmock-spring-boot module integrates gRPC Mock with Spring Boot tests. source
- Stubbing
- It configures gRPC method stubs through a fluent Java API. source
- Supported methods
- It supports unary, server streaming, client streaming, and bidirectional streaming methods. source
- Test lifecycle
- With the JUnit 5 extensions, mappings are cleared after each test and the server shuts down after the test class finishes. source
- Test lifecycle
- With the documented JUnit 5 extensions, stubs are cleared after each test and the server shuts down after the test class finishes. source
- Verification
- Tests can verify method invocations, including invocation counts, status, headers, and request messages. source
Checked against the maker's pages on 8 Oct 2026.