How to write Process/Scenario Test for executing timer event(Unit 5)?

Hi Community,
I have a bpmn model, which contains a timer event between two service tasks. The setting is as following:

and in my unit test, when I am trying to execute the job, I always got the following error message:

java.lang.NullPointerException: Cannot invoke “org.camunda.bpm.extension.process_test_coverage.junit.rules.CoverageTestRunState.addCoveredElement(org.camunda.bpm.extension.process_test_coverage.model.CoveredElement)” because “this.coverageTestRunState” is null

at org.camunda.bpm.extension.process_test_coverage.listeners.IntermediateEventExecutionListener.notify(IntermediateEventExecutionListener.java:32)

this error message is not really helpful, but I assume the problem is in the timer event, as if I remove the timer event in bpmn model, scenario test are passing successfully, here is the ways I found from internet to execute the timer job, but none of them is working for me:
assertThat(processInstance).isWaitingAt(“Event_WaitForPolling”);
1: execute(job());

2: Job job = managementService().createJobQuery().timers().singleResult();
processEngine().getManagementService().executeJob(job.getId());

3: processEngine()
.getManagementService()
.createJobQuery()
.processInstanceId(processInstance.getId())
.timers()
.singleResult();
processEngine().getManagementService().executeJob(job.getId());

I would be very appreciate if someone can help me to solve this issue, thank you very much in advanced!

1 Like