diff --git a/examples/README.md b/examples/README.md index 508f74e076..3e878768ba 100644 --- a/examples/README.md +++ b/examples/README.md @@ -107,6 +107,19 @@ We encourage users to leverage `InProcessTransport` as demonstrated in the examp write unit tests. `InProcessTransport` is light-weight and runs the server and client in the same process without any socket/TCP connection. +Mocking the client stub provides a false sense of security when writing tests. Mocking stubs and responses +allows for tests that don't map to reality, causing the tests to pass, but the system-under-test to fail. +The gRPC client library is complicated, and accurately reproducing that complexity with mocks is very hard. +You will be better off and write less code by using `InProcessTransport` instead. + +Example bugs not caught by mocked stub tests include: + +* Calling the stub with a `null` message +* Not calling `close()` +* Sending invalid headers +* Ignoring deadlines +* Ignoring cancellation + For testing a gRPC client, create the client with a real stub using an [InProcessChannel](../core/src/main/java/io/grpc/inprocess/InProcessChannelBuilder.java),