Hello,
I am trying to port to Junit5 with the coverage library at version 1.0.0 but I am having problems.
My goal is to test the coverage of a process using Spring Boot beans, then initializing the applicationContext first.
While first in the test class I declared
@Autowired
ProcessEngine processEngine
And later I initialized like this:
ProcessEngineTests.init (processEngine);
And then I used the various assertThat () etc …
Now, doing the same thing the engine can’t find the bean springs.
I paste the test class into it for completeness.
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.assertions.ProcessEngineTests;
import org.camunda.bpm.extension.junit5.test.ProcessEngineExtension;
import org.camunda.bpm.extension.process_test_coverage.junit5.ProcessEngineCoverageExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.HashMap;
import java.util.Map;
import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.*;
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.runtimeService;
//import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.*;
@SpringBootTest(
classes = Application.class
)
@ExtendWith(SpringExtension.class)
@ExtendWith(ProcessEngineCoverageExtension.class)
@Deployment(resources = {"project.bpmn"})
public class MyTest {
public static final String PROCESS_KEY = "project";
public static final String TASK = "task";
public ProcessEngine processEngine;
@Autowired
public RuntimeService runtimeService;
@BeforeEach
public void init() {
ProcessEngineTests.init(processEngine);
}
private ProcessInstance startProcess() {
return runtimeService().startProcessInstanceByKey(PROCESS_KEY, "bk");
}
@Test
public void shouldExecuteHappyPath() {
final ProcessInstance instance = this.startProcess();
assertThat(instance).isStarted().isWaitingAt(TASK);
complete(task());
}
}
This is the error:
org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: ${checkInput}. Cause: Cannot resolve identifier 'checkInput'
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:63)
at org.camunda.bpm.engine.impl.el.JuelExpression.getValue(JuelExpression.java:51)
at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior$3.call(ServiceTaskDelegateExpressionActivityBehavior.java:107)
at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior$3.call(ServiceTaskDelegateExpressionActivityBehavior.java:102)
at org.camunda.bpm.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior.executeWithErrorPropagation(AbstractBpmnActivityBehavior.java:90)
at org.camunda.bpm.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior.performExecution(ServiceTaskDelegateExpressionActivityBehavior.java:127)