The protobuf definition is as follows:
syntax = "proto3";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
I need to use Mockito along with JUnit testing.
The encouraged way to test a service is to use the in-process transport and a normal stub. Then you can communicate with the service like normal, without lots of mocking. Overused mocking produces brittle tests that don't instill confidence in the code being tested.
GrpcServerRule
uses in-process transport behind-the-scenes. We now I suggest taking a look at the examples' tests, starting with hello world.
Edit: We now recommend GrpcCleanupRule
over GrpcServerRule
. You can still reference the hello world example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With