ProcessApplication gets loaded in a test although it should not


could someone please help me in the following situation?

  • I have a Spring Boot based process application; the Application class is annotated with @EnableProcessApplication

  • The application also has a REST controller (here I’ll name it MyController) so that it can be accessed via REST calls

  • I have a test where I want to test just the controller aspect of the application, not its process aspect. The test does not touch any Camunda API.

  • For this, I’ve created a test class which has these annotations:
    a. @RunWith(SpringRunner.class)
    b. @WebMvcTest(value = {MyController.class}) // Only load the bean to test

I.e. I restrict the spring application context to just the class I want to test.

The problem: The test fails with the message (root cause)

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

The further analysis from Spring Boot is:

Field camundaBpmProperties in org.camunda.bpm.spring.boot.starter.SpringBootProcessApplication required a bean of type ‘’ that could not be found.

The error occurs even if I set the property camunda.bpm.enabled to false:

@TestPropertySource(properties = "camunda.bpm.enabled=false")

If, in the test class, I define a nested class that defines another SpringBootApplication (without @EnableProcessApplication) like this, the the test works OK:

public static class NoCamundaApplication {

But I would avoid defining such bean in the test because it has nothing in common with the process aspect of the application.

So please: Has anyone an idea why the test fails? I.e. why does Spring try to load the process application if the context has been restricted to just one bean?

Thank you for any hints!

The solution was that I had to further restrict the context that’s built when executing the test. This can be done via the annotation @ContextConfiguration(MyController.class). Then there is no need in the nested class.