Simplified unit testing

Earlier versions of EJBs were very difficult to unit test. In fact, it was difficult to run EJBs outside the container (as of version 2.1). The only way to test them was to deploy them in a container.

Spring Framework brought in the concept of Dependency Injection (DI). We will discuss dependency injection in complete detail in Chapter 2, Dependency Injection.

The dependency injection enables unit testing by making it easy to replace the dependencies with their mocks. We do not need to deploy the entire application to unit test it.

Simplifying unit testing has multiple benefits:

  • Programmers are more productive
  • Defects are found earlier so they are less costly to fix
  • Applications have automated unit tests, which can run in Continuous Integration builds, preventing future defects
..................Content has been hidden....................

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