NullValueException: no processes deployed with key. Probably Camunda uses wrong spring context

Hello,

I have a strange problem with Camunda tests.

I’m writing JUnit tests using @Rule, and org.camunda.bpm.engine.test.mock.Mocks and camunda.cfg.xml with in-memory h2 database.
Also, I have spring boot tests for testing other stuff not related to Camunda.

Everything works fine until I run Camunda tests in IDE along with other tests in my project: I get “…NullValueException: no processes deployed with key…”
When I’m running all the test using mvn clean test, then I get another behavior:

org.camunda.bpm.engine.jobexecutor       : ENGINE-14006 Exception while executing job c859d23d-f442-11ea-ac95-0242bbc78511: 
org.springframework.dao.InvalidDataAccessApiUsageException: The given id must not be null!; nested exception is java.lang.IllegalArgumentException: The given id must not be null!

I see that it tries to execute my REAL spring beans representing Camunda tasks, not that mocked beans!

I could be mistaken, but it looks like Camunda is trying to reuse another spring context, so Camunda tests starting failing.

Could anyone help me with the problem?

Thank you.

Indeed, the current process engine was replaced by another one created during running other tests.

The solution is to add a new property in camunda.cfg.xml file:

<property name="processEngineName" value="test-engine"/>

After defining a new name for the test engine, it started working fine.