我在验证expectNoEvent方面遇到了困难。
考虑以下代码:
StepVerifier.withVirtualTime((Supplier<Publisher<?>>) () -> Flux.just(1, 2, 3).cache(Duration.ofSeconds(10)))
.thenAwait(Duration.ofSeconds(11))
.expectNoEvent(Duration.ofSeconds(1))
.verifyComplete();
它总会失败,因为没有任何完整的信号。
测试noEvent的最佳方法是什么?
答案 0 :(得分:0)
不确定您要在此处测试的内容... noEvent
是StepVerifier
的概念。您正在混合使用thenAwait()
提升(虚拟)时钟的Duration
,但允许事件渗透通过expectNoEvent
,同时将(虚拟)时钟推进Duration
,但是在该持续时间内发生事件(onNext / onComplete / onError)时会失败。