reactor / lite-rx-api-hands-on

Lite Rx API Hands-On with Reactor Core 3
1.05k stars 959 forks source link

Test for Mono.never() is ineffective #52

Closed dclarke18 closed 4 years ago

dclarke18 commented 6 years ago

lite-rx-api-hands-on/src/test/java/io/pivotal/literx/Part02MonoTest.java includes the test method below which passes even with my change so is ineffective. Should the test be changed to register a doOnNext(fail())? Should StepVerifier have a better way of checking nothing produced from the Flux/Mono for a period?

@Test
    public void noSignal() {
        //Mono<String> mono = workshop.monoWithNoSignal();
                 Mono<String> mono = Mono.just("ShouldFail");
        StepVerifier
                .create(mono)
                .expectSubscription()
                .expectNoEvent(Duration.ofSeconds(1))
                .thenCancel()
                .verify();
    }  
PyvesB commented 5 years ago

Same issue here. I believe this is a bug in reactor-core's step verifiers, I raised the following issue to flag this up: https://github.com/reactor/reactor-core/issues/1913

In the meantime, the following test replacement is a workaround (i.e. it will fail as expected for Mono.just("ShouldFail")):

@Test
public void noSignal() {
    Mono<String> mono = workshop.monoWithNoSignal();
    StepVerifier.create(mono.timeout(Duration.ofSeconds(1L)))
            .verifyError(TimeoutException.class);
}