Reputation: 2210
is this a best practice while performing integration tests on the gRPC services? i.e. opening and closing channels after each unit test using annotations @BeforeEach and @AfterEach
private ManagedChannel channel;
private DepartmentServiceGrpc.DepartmentServiceBlockingStub deptService;
@BeforeEach
public void initEach(){
channel = ManagedChannelBuilder.forAddress("localhost", 8080)
.usePlaintext()
.build();
deptService = DeptServiceGrpc.newBlockingStub(channel);
}
@AfterEach
public void cleanUpEach(){
channel.shutdown();
}
Upvotes: 1
Views: 4882
Reputation: 24593
If you're using JUnit 4, you can use the GrpcCleanupRule
. If you're using JUnit 5, you can use the OSS grpc-test I created.
Upvotes: 2
Reputation: 878
gRPC provides junit4 rule called GrpcCleanupRule. Note that it is junit4 rule.
Upvotes: 0