Create ProcessEngineRule using processes.xml deployment descriptor with JUnit

Hi,

We’re using the embedded Spring Boot Application, and would like to test our BPMNs/DMNs using JUnit.

After looking through various posts and not able to find the correct solution, I’m posting this.

How do we create ProcessEngineRule using “processes.xml” deployment descriptor with JUnit.

We do not want to add “*.cfg.xml” merely to be able to unit test.

I was initially using AbstractProcessEngineRuleTest, but then as per my understanding StandaloneInMemoryTestConfiguration would not read processes.xml.

Is there a way we can achieve this without having to add a separate config file?

Refer this page for testing bpmn and dmn.

For testing processes you need camunda.cfg.xml config file (src/test/resources) to configure process engine rule.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  <bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
    <property name="history" value="full" />
    <property name="expressionManager">
      <bean class="org.camunda.bpm.engine.test.mock.MockExpressionManager"/>
    </property>
    <property name="processEnginePlugins">
      <list></list>
    </property>
  </bean>
</beans>

Your test class should look like:

@RunWith(MockitoJUnitRunner.class)
@Deployment(resources = "MyProcess.bpmn")
public class MyProcessTest {

	public ProcessEngineRule processEngineRule = new ProcessEngineRule();

    @Test
	public final void testMyProcessTask() {
		ProcessInstance processInstance = runtimeService().startProcessInstanceByKey(PROCESS_DEFINITION_KEY,
				withVariables("processInitiator", "demo"));
		assertThat(runtimeService().createProcessInstanceQuery().count()).isEqualTo(1L);
     }
}

@aravindhrs ,

Thanks for your response.

Actually, we didn’t wanna create “Camunda.cfg.xml” explicitly for testing.

I’m now referring the following example:

Thanks