-
Couldn't load subscription status.
- Fork 3
MultiThreading and Concurrency Execution
Under the hood Sprimber supports the Node tree. Each node can play a role of container of specific type or leaf with action of specific type. Like StepContainer node may have relations to Before, After and Target nodes, that means actions that will be executed before and after step respectively and actually the step(target).
Sprimber adapter for Cucumber/Gherkin syntax supports next container-like Node roles:
- testSuite
- testCase
- test
- stepContainer
Each node can be executed using it's own executor or executed synchronously using the current thread. To achieve it node execution engine looking for executor beans by mask {node_role}Executor
By default Sprimber supports concurrency execution on test and test case level, for this default implementation of bean testExecutor and testCaseExecutor added to auto-configuration.
NOTE: The settings for testExecutor bean will setup actual number of concurrently executing tests. But the size for testCaseExecutor pool should be equal or greater then testExecutor pool size, otherwise the size of testCaseExecutor will determine the number of concurrently executing tests.
@Bean
@ConditionalOnMissingBean(name = "testExecutor")
public Executor testExecutor() {
return getDefaultExecutor("TestExecutor-");
}
@Bean
@ConditionalOnMissingBean(name = "testCaseExecutor")
public Executor testCaseExecutor() {
return getDefaultExecutor("TestCaseExecutor-");
}
private ThreadPoolTaskExecutor getDefaultExecutor(String s) {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(3);
taskExecutor.setMaxPoolSize(3);
taskExecutor.setThreadNamePrefix(s);
taskExecutor.initialize();
return taskExecutor;
}
To achieve custom settings, like configurable number of threads or fine-grade tuning required to add the same bean to context with extra additions
@Bean
public Executor testExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(15);
taskExecutor.setMaxPoolSize(15);
taskExecutor.setThreadNamePrefix("customTestExecutor-");
taskExecutor.initialize();
return taskExecutor;
}
@Bean
public Executor testCaseExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setCorePoolSize(15);
taskExecutor.setMaxPoolSize(15);
taskExecutor.setThreadNamePrefix("customTestCaseExecutor-");
taskExecutor.initialize();
return taskExecutor;
}