Using @MockBean gets "Cannot stop service..." Error - SpringBootTest

Am having issues when using @MockBean in conjunction with Camunda.
Getting Error:
Cannot stop service org.camunda.bpm.platform.process-engine:type=default: no such service registered: service is null.
Single Tests work OK but will get this Error when running full Test Suite.
Using “@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)” in Tests.

This is demonstrated in the following Repository link:

we had an issue with MockBean in the past, please check if Cannot register service while running unit tests using MockBean · Issue #208 · camunda/camunda-bpm-spring-boot-starter · GitHub sounds familiar to your problem. In that case, Oliver found this solution:

Within your tests you are trying to register multiple beans within the same application context. This is wrong usage of spring (testing). This is not related to the extension.


use different contexts/configurations (one to use @Autowired private IntService intService; and one to use

@MockBean private IntService intService;).


dirty the context, for example:

public class IntServiceMockTest {

  private IntService intService;

Does that help you?

hmm not sure if this is a similar problem.
I dont understand what you mean by the first hint, we’ve tried the second hint but this doesnt seem to work either.

Are you able to run the test suite on the attached respitory to help understand and possible resolve the issue?

No, I haven’t checked your module so far, just posted the first thing that came to my mind … will have a look at it.

wondered if you had a chance to look into this yet? :smile:

Had it run on my machine, also switched to latest extension and spring boot version … same result as you had …

no further ideas so far, sorry.