A Java geek > Spring configuration modularization for Integration Testing
Object-Oriented Programming advocates for modularization in order to build small and reusable components. There are however other reasons for this. In the case of the Spring framework, modularization enables Integration Testing, the ability to test the system or parts of it, including assembly configuration.
Why is it so important to test the system assembled with the final configuration? Let's take a simple example, the making of a car. Unit Testing the car would be akin to testing every nuts and bolts of the car separately, while Integration Testing the car would be like driving it on a circuit. By testing only the car's components separately, selling the assembled car is a huge risk as nothing guarantees it will behave correctly in real-life conditions.
Now that we have asserted Integration Testing is necessary to guarantee the adequate level of internal quality, it's time to enable Integration Testing with the Spring framework. Integration Testing is based on the notion of SUT. Defining the SUT is to define the boundaries between what is tested and its dependencies. In nearly all cases, test setup will require to provide some kind of test double for each required dependency. Configuring those test doubles can only be achieved by modularizing Spring configuration, so that they can replace dependent beans located outside the SUT.
Read full article from A Java geek > Spring configuration modularization for Integration Testing
No comments:
Post a Comment