Tests instable

Hello,

I setup a Camunda Spring Boot application: https://github.com/r-winkler/camunda-payment-retrieval

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.

CamundaSpringBootTest:

CamundaUnitTest:

Hi @r-winkler,

thats interesting. Could you please add the line number where of your assertion failed?

Cheers, Ingo

Hi @Ingo_Richtsmeier,

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.

Regards René

Hi @r-winkler,

then it’s worth to have a look at the BPMN file. Could you upload it here?

Hi @Ingo_Richtsmeier

Here is the BPMN:

Hi @r-winkler,

I just cloned your repo and run the tests by myself. It’s deterministic, I got the same errors running mvn clean test.

I’ve tried another configuration for the Junit test engine, without changes in the result.

Maybe Maven didn’t clean up the memory so that the assertion gets confused with other process instances?

Interesting, time consuming topic…

Hi @Ingo_Richtsmeier

Thank you for looking into it.

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.

Faced a similar issue.

Found ugly workaround - place all test in the same class