使用 runAsync() 块调用另一个方法的测试方法
对于您遵循的任何建议或做法,我将不胜感激。
我们使用 Mockito 和 Junit4/5 来编写单元测试。但是,我发现一些测试在生产环境中失败 (在测试结束时,您验证对具有 runAsync 块的方法的调用)。
除了添加超时来验证或排除 runAsync() 块之外,是否存在任何选项来修复这些测试? 提前TQ。
I would be grateful for any advice or practices which you follow.
We use Mockito and Junit4/5 to to write unit tests. However, I see that some tests fail at prod
(when at the end of a test you verify calling of methods which have runAsync block).
Are there exists any options to fix these tests except adding timeout to verify or excluding runAsync() blocks?
TQ in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定您的用例到底是什么样的,但这听起来像是 Awaitility 的使命。你去那里查过吗?
Awaility-usage-examples
另外,请不要排除 runAsync() 块。它们是可测试的:)
Not sure what your use case looks like exactly, but it sounds like the mission of Awaitility. Have you checked there?
Awaility-usage-examples
And nonono, please don't exclude runAsync() blocks. They are testable :)