Spring-Based Testing

When integrating with Spring, business processes can be tested very easily (in scope 2, see Testing Scopes) using the standard Camunda testing facilities. The following example shows how a business process is tested in a typical Spring-based unit test:

public class MyBusinessProcessTest {

  private RuntimeService runtimeService;

  private TaskService taskService;

  public ProcessEngineRule processEngineRule;

  public void simpleProcessTest() {
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("My Task", task.getName());

    assertEquals(0, runtimeService.createProcessInstanceQuery().count());


Note that for this to work, you need to define a ProcessEngineRule bean in the Spring configuration (which is injected by auto-wiring in the example above).

<bean id="processEngineRule" class="org.camunda.bpm.engine.test.ProcessEngineRule">
  <property name="processEngine" ref="processEngine" />

On this Page: