Running junit and after that testing using the ProcessCoverage.calculate(processEngine)
Please let me know why it thows NullPointerException. Is that a version or dependency issue?
Thanks in advance
@Ingo_Richtsmeier- Thanks for the reply. I have included the dependency and followed the github URL from mobile(As github is blocked from DNS in the Laptop). could see this snippet
@Rule
@ClassRule
public static ProcessEngineRule rule=TestCoverageProcessEngineRuleBuilder.create().build();
Then started to run the JUNIT but it gets terminated after displaying the console everytime.
16:47:58.447 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.vodafone.iot.gdsp.changecsp.controller.FlowTest_3]
16:47:58.507 [main] DEBUG org.camunda.bpm.engine.test - ==== BUILDING PROCESS ENGINE ========================================================================
16:47:58.601 [main] DEBUG org.camunda.bpm.engine.test - ==== BUILDING PROCESS ENGINE ========================================================================
@Ingo_Richtsmeier- It says it is expecting activiti.cfg.xml and FileNotFoundException. please let me know the importance of file and what should be included here. Is there a way to avoid XML as it is a spring-boot project.
@Ingo_Richtsmeier- Thanks for the reply. I have included the xml file and now it says ENGINE-00005 Exception while initializing process engine ENGINE-03017 Could not perform operation 'create' on database schema
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "ACT_HI_PROCINST" already exists; SQL statement:
After adding the below XML with bean id-processEngineConfiguration.It says DBException.please let us know the exat issue.
camunda.cfg.xml:
@SpringBootTest(classes=Application.class)
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
public class FlowTest_3 {
@InjectMocks
HLRAdaptorRequestCreation creation;
@Mock
RestTemplate template;
@Autowired
ProcessEngine engine;
Using @SpringBootTest by default autowires process engines everything for the test class but when i try to use ProcessEngineRule it complains about cfg.xml which is something required for creating process engine bean creation My query here is When ProcessEngine is auto-wired why does it look for cfg.xml ?
Also tried removing auto-wiring and using cfg.xml then when the workflow goes and the developer autowired all the process engine and runtimeservice in the JavaDelegate implementations so Their process engine scope refers to null (As cfg.xml used is only for test purposes).
the ProcessEngineRule starts it’s own process engine with an in-memory database and injects it into the test class.
This is my favorite to write plain Junit tests, testing the expressions and tasks of the process. Here the eingie is configured from camunda.cfg.xml file.
When you start the process engine as a SpringBootTest, you get an integration test scenario. The engine will pickup the configuration from the spring boot environment e.g. application.yml, or propertiers, or whatever spring boot uses.
You can’t mix both approaches as you get the errors you already saw. The two engines confilct each other.
Thanks again. I have expected this situation of conflict and tried removing @SpringBootTest to use cfg.xml and ProcessEngineRule. As said getting the ProcessInstance reference from ProcessEngineRule
After this i have run the mvn clean package and as per the result it should leave HTML files of the executed flow but it doesn’t create any such files in the target folder. Is that a version conflict ?
Test is successful but it is not able to pickup the test related properties when tried with @TestPropertySource but the main concern here is the HTML files.
@Ingo_Richtsmeier- That was the partial code, starting the process and getting the ProcessInstance reference as well. I have tried using @ClassRule. I’m just trying with all the possiblities as i got struck here.