I’ve already written a couple of tests. When tests are executed one by one, all are working fine. However, there is a problem when I run the tests together, or more specifically when I run the
CamundaSpringBootTest and CamundaUnitTest together (and in this order). I gives me an error in the CamundaUnitTest saying that the processInstance has already finished:
“java.lang.AssertionError: Expecting ProcessInstance {id=‘7’, processDefinitionId=‘payment-retrieval:1:4’, businessKey=‘null’} to be unfinished, but found that it already finished!”
It seems for me like some state (e.g. H2 databse?) is not reset between the tests? I have already tried using @DirtiesContext and @Transactional, but without success.
Would be great if somebody can look at it. Thanks.
Both tests in CamundaUnitTest.java are failing, so the line numbers are 37 and 58.
This is the first assertion in both tests where I check that the instance is waiting at some task.
If I run the CamundaUnitTest individually, then the H2 database will be set up completely fresh according to the logs. If both tests run together, you can see in the logs that no fresh h2 database is started. Therfore, I guess the error is related to Spring somehow, rather than to Maven.
If I place @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) in my CamundaSpringBootTest, then the CamundaUnitTest fails completly as it tries to query the database (instead of creating it) which is not is not available.