I have a method annotated with @Async say
@Async public void createArticles(long Id){}
but I'm just trying to a cucumber test of that method. Is it possible to test it synchronously?
I have a method annotated with @Async say
@Async public void createArticles(long Id){}
but I'm just trying to a cucumber test of that method. Is it possible to test it synchronously?
Create your async configuration class:
@Configuration
@EnableAsync
@ConditionalOnProperty(name = "async.enabled", havingValue = "true")
public class SpringAsyncConfig {
// Your configuration here
}
the annotation @ConditionalOnProperty
here will create this bean if only the configuration value async.enabled
is true
Then in the configuration file if you are going to run the integration test you can set the value to false
async.enabled = false
or if you are using Spring profiles you can always set the value to true
in other profiles configuration files like application.properties
, application-dev
and set to false
in application-integration.properties