ProjectReactor StepVerifier如何测试expectNoEvent?

时间:2017-03-12 12:37:18

标签: java project-reactor

我在验证expectNoEvent方面遇到了困难。

考虑以下代码:

        StepVerifier.withVirtualTime((Supplier<Publisher<?>>) () -> Flux.just(1, 2, 3).cache(Duration.ofSeconds(10)))
            .thenAwait(Duration.ofSeconds(11))
            .expectNoEvent(Duration.ofSeconds(1))
            .verifyComplete();

它总会失败,因为没有任何完整的信号。

测试noEvent的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

不确定您要在此处测试的内容... noEventStepVerifier的概念。您正在混合使用thenAwait()提升(虚拟)时钟的Duration,但允许事件渗透通过expectNoEvent,同时将(虚拟)时钟推进Duration,但是在该持续时间内发生事件(onNext / onComplete / onError)时会失败。