[Junit5] ProcessEngineRule compatibility with Junit5

Hi Everyone,

Does anyone have tested camunda processes with JUnit5?

I’m getting NullPointerException when i access runtimeService from ProcessEngineRule.

ProcessEngineRule processEngineRule = TestCoverageProcessEngineRuleBuilder.create().build();

runtimeService = processEngineRule.getRuntimeService();

ProcessInstance processInstance =runtimeService.startProcessInstanceByKey("OneActivityProcess"); //throws NPE

Or should I’ve fallback to Junit4 ?

Hi @aravindhrs,

@Rule is JUnit4 only. Have a look at this extension to write process tests with JUnit5 and @ExtendWith(ProcessEngineExtension.class): GitHub - camunda-community-hub/camunda-bpm-junit5: Camunda Community Extension to write process tests with JUnit5

Hope this helps, Ingo

1 Like

@Ingo_Richtsmeier Thanks :+1:

Can we change the below config StandaloneInMemProcessEngineConfiguration to ProcessCoverageInMemProcessEngineConfiguration?

With JUnit5 I hope it has support for ProcessCoverageInMemProcessEngineConfiguration. What do you think?

<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
<bean id="processEngineConfiguration"

Hi @aravindhrs,

process test coverage and JUnit 5 is still an open issue: Feature Request > Add support for JUnit 5 · Issue #45 · camunda-community-hub/camunda-bpm-process-test-coverage · GitHub.

The latest refactoring from Simon should make it easier to get it done.

Currently I’m trying to offer greater flexibility to provide a preconfigured engine to the JUnit 5 extension: camunda-bpm-junit5/core/src/test/java/org/camunda/bpm/extension/junit5/registerExtension at use_own_process_engine · camunda-community-hub/camunda-bpm-junit5 · GitHub

But it is still work in progress as the build fails.

Hope this helps, Ingo

1 Like

@Ingo_Richtsmeier How to mock the Process Engine services in the facade api over camunda java api?

For example,

	private HistoryService historyService;

	public HistoricProcessInstanceDto getHistoricProcessInstance(String businessKey, String processDefinitionKey) {
		log.info("Querying historic process instance for businessKey: {}", businessKey);

		HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()

         if (Objects.nonNull(historicProcessInstance)) {
			HistoricProcessInstanceDto historicProcessInstanceDto = HistoricProcessInstanceDto
			return historicProcessInstanceDto

		return null;

class ProcessInstanceHistoryServiceTest {

	HistoryService historyService;

	ProcessInstanceHistoryService processInstanceHistoryService = new ProcessInstanceHistoryServiceImpl();

	void testGetHistoricProcessInstance() {

		HistoricProcessInstanceDto historicProcessInstanceDto = processInstanceHistoryService.getHistoricProcessInstance("Test1",
		//assertions based on historicProcessInstanceDto

It throws NPE. Have you tried mocking process engine services like above scenario?

Note that here i’m not testing the bpmn process, instead i’m testing the wrapper java method which has process engine services.

Solved with the below snippets:


@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private HistoryService historyService;

Hi, Ingo

I dont seem to be able to test my dmn file with the @ExtendWith(ProcessEngineExtension.class) functionality. It works fine for bpmn files.

What is the correct way to test input/output of dmn tables?



Hi @FrankReneSorensen,

this is a running example from my latest training:

public class ProcessJUnitTest {
  @Deployment(resources = "tweetApproval.dmn")
  public void testTweetApprovalIBM() {
    Map<String, Object> variables = withVariables(
        "content", "ibm process server is slow",
        "email", "don't care");
    DmnDecisionTableResult tableResult = decisionService().evaluateDecisionTableByKey("tweetApproval", variables);
    assertThat(tableResult.getFirstResult()).contains(entry("approved", false));

Hope this helps, Ingo

Do you have the training available? I would very much like to attend, if it is possible?



Hi @FrankReneSorensen,

this test is just a small piece of our Camunda Platform for Java Developer training: Camunda Platform Training for Java Developers - Camunda.

If you use Camunda Platform for a longer time, you may see some pieces you are already familiar with.

Hope this helps, Ingo

Hi guys,

Just to get your feedback on the following point:

In JUnit4, the DMN Engine dependency comes with a JUnit Rule, tests in JUnit4 use the DmnEngineRule for bootstrapping the DMN engine, and then get the DMN engine with

  public DmnEngineRule dmnEngineRule = new DmnEngineRule();

  public void test() {
    DmnEngine dmnEngine = dmnEngineRule.getDmnEngine();

As demonstrated in Testing Decisions with the DMN Engine | docs.camunda.org
All in one single artifact: camunda-engine-dmn.

In JUnit5, the Rule is obsolete, as @Rule is replaced by @ExtendWith. The new annotation bootstraps the engine, same principle so far, then to get the DMN we have to ask the decisionService to evaluate the table as:

DmnDecisionTableResult tableResult = decisionService().evaluateDecisionTableByKey("tweetApproval", variables);

The decision service is only available in the artifact: camunda-engine-7.X.jar, so one more artifact.

Meaning, I have to include the whole process engine artifact in order to access the decision service in my tests, even if I do not want to access the other services.

Is there a way to test the DMN Engine with only the DMN engine artifact in JUnit5, as it was possible in JUnit4 ?

Any input is greatly appreciated.