Spring Boot Tests Failing due to ProcessEngineException

I’m currently writing tests for my Spring Boot Camunda application.
My tests use the @SpringBootTest annotation which creates a Spring Application Context. My tests are all working fine when run in isolation, but when I try to run the whole test suite then one or more of the tests will fail with a ProcessEngineException.
This is due to the Camunda SpringProcessApplication reacting to the ContextClosedEvent when the @SpringBootTest annotation creates and destroys the ApplicationContext.

Has anyone encountered this issue before?

Example stacktrace:

2018-09-12 10:49:21.372 INFO 20275 — [ Thread-14] o.s.w.c.s.GenericWebApplicationContext : Closing org.springframework.web.context.support.GenericWebApplicationContext@6f26a60e: startup date [Wed Sep 12 10:48:59 IST 2018]; root of context hierarchy
2018-09-12 10:49:21.377 INFO 20275 — [ Thread-14] org.camunda.bpm.container : ENGINE-08051 Process application null undeployed
2018-09-12 10:49:21.378 WARN 20275 — [ Thread-14] o.s.w.c.s.GenericWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.RuntimeException: org.camunda.bpm.engine.exception.NullValueException: Cannot stop service org.camunda.bpm.platform.process-engine:type=default: no such service registered: service is null
at org.camunda.bpm.engine.spring.application.SpringProcessApplication.onApplicationEvent(SpringProcessApplication.java:99) ~[camunda-engine-spring-7.8.0.jar:7.8.0]
at org.camunda.bpm.engine.spring.application.SpringProcessApplication.onApplicationEvent(SpringProcessApplication.java:48) ~[camunda-engine-spring-7.8.0.jar:7.8.0]
at com.guru.connect.ConnectApplication$$EnhancerBySpringCGLIB$$b8c60a32.onApplicationEvent() ~[main/:na]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:399) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:353) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:996) ~[spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:933) [spring-context-5.0.4.RELEASE.jar:5.0.4.RELEASE]
Caused by: org.camunda.bpm.engine.exception.NullValueException: Cannot stop service org.camunda.bpm.platform.process-engine:type=default: no such service registered: service is null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_152]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_152]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_152]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_152]
at org.camunda.bpm.engine.impl.util.EnsureUtil.generateException(EnsureUtil.java:344) ~[camunda-engine-7.8.0.jar:7.8.0]
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:49) ~[camunda-engine-7.8.0.jar:7.8.0]
at org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull(EnsureUtil.java:44) ~[camunda-engine-7.8.0.jar:7.8.0]
at org.camunda.bpm.container.impl.jmx.MBeanServiceContainer.stopService(MBeanServiceContainer.java:117) ~[camunda-engine-7.8.0.jar:7.8.0]
at org.camunda.bpm.container.impl.jmx.MBeanServiceContainer.stopService(MBeanServiceContainer.java:105) ~[camunda-engine-7.8.0.jar:7.8.0]
at org.camunda.bpm.container.impl.RuntimeContainerDelegateImpl.unregisterProcessEngine(RuntimeContainerDelegateImpl.java:85) ~[camunda-engine-7.8.0.jar:7.8.0]
at org.camunda.bpm.spring.boot.starter.SpringBootProcessApplication.destroy(SpringBootProcessApplication.java:80) ~[camunda-bpm-spring-boot-starter-2.3.0.jar:2.3.0]
at org.camunda.bpm.engine.spring.application.SpringProcessApplication.onApplicationEvent(SpringProcessApplication.java:93) ~[camunda-engine-spring-7.8.0.jar:7.8.0]
… 9 common frames omitted

Of course, I figure out the issue as soon as I make the forum post.

The problem was that due to work I was previously doing, my main Spring Boot application class was extending SpringBootProcessApplication. This was no longer necessary and removing this solved my problem.