简体   繁体   English

void @Async 方法的单元测试用例

[英]unit test case for void @Async method

I need to write unit test case for asynchronous method which doesn't return any value.我需要为不返回任何值的异步方法编写单元测试用例。 Which is the best practice to test asynchronous method in spring boot and junit 5哪个是在 spring boot 和 junit 5 中测试异步方法的最佳实践

You can write a normally test, ignoring the async and catching the possible exceptions.您可以编写一个正常测试,忽略异步并捕获可能的异常。

For the test no matter if it's asynchronous, and yes if the code work as expected :)对于测试,无论它是否是异步的,如果代码按预期工作,则是的 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM