Ease of unit testing

If you want to test the applications developed using Spring, it is quite easy. The main reason behind this is that the environment-dependent code is available in this framework. Earlier versions of EJBs were very difficult to unit test. It was difficult to even run EJBs outside the container (as of version 2.1). The only way to test them was to deploy them in a container. 

The Spring Framework introduced the DI concept. We will discuss DI in complete detail in Chapter 2, Spring Best Practices and Bean Wiring Configurations. The DI enables unit testing. This is done by replacing the dependencies with their mocks. The entire application need not be deployed to unit test.

Unit testing has multiple benefits:

  • Improving the productivity of programmers
  • Detecting defects at earlier stages, thereby saving the cost of fixing them
  • Preventing future defects by automating unit tests in applications that are running in continuous integration (CI) builds
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset