Mock new Services and Components in existing JUnit tests

Viewed 21

Some JUnit tests will stop working when adding new Services, Components, etc.. in your SpringBoot application. As an obvious solution you should add a mocked instanced in the broken unit tests. I am looking for a solution to auto-mock the missing objects in your tests. This solution was proposed four years ago and it seems good @MockBeans example use

Any other great ideas?

I am adding some updates as the idea of the required solution become more clear. Spring boot has the concept of Test Slice, so what I need here is to create custom Test Slices that allow me to focus on testing some components of my system without completely loading other components. By component I mean one more services, components, repositories, etc.

0 Answers
Related