You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently writing unit test where I'm verifying a Camunda BPM process definition is correctly configured. The application defines multiple beans for different purposes including the multiple ones you need to make use of Camunda API declare in resources.groovy
A typical application resources.groovywould look like this:
As you may see Camunda, requires a considerable amount of beans/code. Although you can create separated spring bean definition(doWithSpring(), xml, @Config ) for your unit test to declare only beans necessary for your test spec, it is better to use the same source to run the application(resources.groovy) and your test meeting with the DRY principle but the problem is that loadExternalBeanDefinion() loads all beans when for the purpose of testing, you only need to load a subset of what it is declared(in my case only Camunda Beans).
Is there any way to enhance GrailsUnitTest trait and/or GrailsApplicationBuilder class in order to enable a bean inclusion and/or exclusion Setsimilar to the plugin load feature already offered by Grails testing support?
For example:
classProcessDefinitionSpecextendsSpecificationimplementsAutowiredTest {
ClosuredoWithSpring() {{ ->
taskListener1(InstanceFactoryBean, Mock(ApprovalTaskListener))
}}
booleanloadExternalBeans() {true }
Set<String>excludingBeans(){
["userPasswordEncoderListener", "authenticationEntryPoint", "logoutSuccessHandler"]. toSet()
}
// ALL TEST BELOW HERE
}
or using an inclusion Set:
classProcessDefinitionSpecextendsSpecificationimplementsAutowiredTest {
ClosuredoWithSpring() {{ ->
taskListener1(InstanceFactoryBean, Mock(ApprovalTaskListener))
}}
booleanloadExternalBeans() {true }
Set<String>includinglBeans(){
["identityProviderSessionFactory", "processEngineConfiguration", "processEngine", "runtimeService", "taskService", "repositoryService"]. toSet()
}
// ALL TEST BELOW HERE
}
I hope I explain the use case well!
Saludos
Hugo
The text was updated successfully, but these errors were encountered:
Grails team,
I'm currently writing unit test where I'm verifying a Camunda BPM process definition is correctly configured. The application defines multiple beans for different purposes including the multiple ones you need to make use of Camunda API declare in
resources.groovy
A typical application
resources.groovy
would look like this:As you may see Camunda, requires a considerable amount of beans/code. Although you can create separated spring bean definition(
doWithSpring()
, xml,@Config
) for your unit test to declare only beans necessary for your test spec, it is better to use the same source to run the application(resources.groovy
) and your test meeting with the DRY principle but the problem is thatloadExternalBeanDefinion()
loads all beans when for the purpose of testing, you only need to load a subset of what it is declared(in my case only Camunda Beans).Is there any way to enhance
GrailsUnitTest
trait and/orGrailsApplicationBuilder
class in order to enable a bean inclusion and/or exclusionSet
similar to the plugin load feature already offered by Grails testing support?For example:
or using an inclusion
Set
:I hope I explain the use case well!
Saludos
Hugo
The text was updated successfully, but these errors were encountered: