Closed tomnoah1 closed 12 months ago
I run it in parallel with junit. just initialize a new instance for every test run in a @BeforeEach
grpcMock = GrpcMock.grpcMock().build();
grpcMock.start();
and get the port in each test with grpcMock.getPort()
And do you also run there the configureFor(...) function? configureFor is static so it might cause problem when running in parallel
I don't use the global instance at all so i also don't use the configureFor method. I only call instance methods on the grpcMock instance that I create myself.
Hi @tomnoah1 if you're having some issues with parallelism and you're running multiple test classes on the same thread at the same time, then as mentioned by @christophsturm you shouldn't use any of the static method and should use only the methods directly on the grpcmock
instance.
Also make sure that you're using 0
for port value so that each grpmock instance would have a dynamic port (or use in-process servers).
Thank you very much! I managed to do it. What I was missing is that I can use the 'register' method directly instead of the static function 'stubFor'. After your comments I looked deeper and found it.
Thanks.
Hi, First of all, thank you very much for this library. We are using it for our unit test and it really helps us.
Since you defined "configureFor" as a static function, and since you implemented your library to create global static gRPC Mock instance, it is impossible to use this library in order to run multiple instances of gRPC mock server in parallel on the same time on different ports.
It is important for us since we are running our unit tests in parallel and we have multiple gRPC servers that we want to mock while we are testing our clients against them. We wanted to ask you if is it possible to change it so we can run it in parallel as I described, and if so, if you will be able to change it.
Thanks again.