I am using StepVerifier
to test values:
@Test
public void testStuff() {
Thing thing = new Thing();
Mono<Thing> result = Mono.just(thing);
StepVerifier.create(result).consumeNextWith(r -> {
assertEquals(thing, r);
}).verifyComplete();
}
What I'd like to do now is test for the absence of an item in the Mono. Like this:
@Test
public void testNoStuff() {
Mono<Thing> result = Mono.empty();
StepVerifier.create(result)... // what goes here?
}
I want to test that the Mono is in fact empty. How do I do that?
Simply use verifyComplete()
. If the Mono
emits any data, it will fail the stepverifier as it doesn't expect an onNext
signal at this point.