When I write tests that verify reactive components I usually use the StepVerifier
with the following pattern:
StepVerifier.create(...)
.assertNext(...)
...
.verifyComplete();
This approach works nice but sometimes it is necessary to grab the produced value and continue the test scenario using it. In this case I have to switch to something like:
var producedValue = publisher.block();
assertThat(producedValue)...;
someOtherAction(producedValue);
The latter is completely fine and works as expected however I feel that I might miss something and StepVerifier
API should have an option for doing this as well.
Is there any way to avoid blocking in such scenario and still stick to the StepVerifier
?