在单元测试期间是否可以禁用Spring的@Async? [英] Is it possible to disable Spring's @Async during unit test?
本文介绍了在单元测试期间是否可以禁用Spring的@Async?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用注释的方法@Async
说
@Async
public void makeFood() {}
但我只是想测试一下该方法的逻辑。是否可以同步测试?
but I'm just trying to test the logic of that method. Is it possible to test it synchronously?
推荐答案
是的,只要您的配置没有 @ EnableAsync
,该方法将同步执行。
Yes, as long as your configuration does not have @EnableAsync
, the method will be executed synchronously.
这篇关于在单元测试期间是否可以禁用Spring的@Async?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文