The scenario is as follows.
I have a controller that I want to test which has a dependency on a single service injected through the constructor. The injected service its self is dependent on another service injected through its constructor. At runtime, autowired injection creates the services and injects them as intended.
The problem is that when testing the controller in a unit test I cant just mock the service that the controller is directly dependent on, for some reason autowire attempts to create the entire chain unless I provide mocks for all the dependencies.
I would expect that if my test had a @MockBean for all direct dependencies of the controller that would be sufficient but that does not appear to be the case. The test has to provide mocks for every dependency in the graph.
This isn't much of a problem with this simple case but it becomes very problematic when there are dozens of services and components in the dependency graph.
How can I get autowire and the WebMvcTest to stop at the top level of the graph when all the direct dependencies are mocked?