java - 单元测试无限重复通量
问题描述
给定一个永远重复的 Flux,我们如何对此进行单元测试?假设我要断言第一组元素 [1,2,3,4,5]
StepVerifier.
withVirtualTime(() -> Flux.just(1,2,3,4,5).repeatWhen(c -> c.delayElements(Duration.ofSeconds(1)).log()))
.thenAwait(Duration.ofSeconds(1))
.expectNext(1)
.thenAwait(Duration.ofSeconds(4))
.expectNext(2,3,4,5)
.thenConsumeWhile(x -> true) // what is the right behaviour to be added here ?
```
解决方案
对于“无限”通量,您唯一的选择可能是thenCancel().verify()
推荐阅读
- javascript - 从插件 vue 设置道具值
- ionic-framework - 如何根据ionic4中的滚动显示\隐藏按钮
- azure - 401 在发布符号路径构建步骤期间未经授权
- ubuntu - apt-cacher-ng 403 禁止在特定包上
- python - 如何在极坐标图中使用颜色条?
- hyperledger-fabric - Convector Framework CLI 在安装链码时返回错误
- javascript - 未捕获的 SyntaxError:将参数添加到 jstl 中的 javascript 方法时出现无效或意外的标记
- html - 模态被搞砸了,现在溢出了
- ios - 在 Swift 中使用 Glimpse 时将文档目录指定为文件输出 URL
- objective-c - 如何在mac应用程序中获取屏幕分辨率的纵横比