在单元测试期间是否可以禁用Spring的@Async?

时间:2015-04-28 20:59:53

标签: java spring asynchronous

我有一个用// 1. Create your new app domain... var newDomain = AppDomain.CreateDomain(...); // 2. call domain.ExecuteAssembly, passing in this process and the "/initializingappdomain" argument which will cause the process to exit right away newDomain.ExecuteAssembly(GetProcessName(), new[] { "/initializingappdomain" }); private static string GetProcessName() { return System.IO.Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName.Replace(".vshost", "")); } // 3. Use your app domain as you see fit, Assembly.GetEntryAssembly will now return this hosting .net exe. 说明

注释的方法
@Async

但我只是想测试该方法的逻辑。是否可以同步测试它?

1 个答案:

答案 0 :(得分:9)

是的,只要您的配置没有@EnableAsync,该方法就会同步执行。