img
.
Test Category
Description
Common Tools
The user acceptance test simulates the actual IBM Rational TestManager,
User acceptance test
HP Quality Center
working conditions of the new system,
including the user manuals and procedures.
Extensive user involvement in this stage of
testing provides the user with invaluable
training in operating the new system. It also
benefits the programmer or designer to see
the user experience with the new programs.
This joint involvement encourages the user
and operations personnel to approve the
system conversion.
In this chapter, we will focus on the implementation of the three kinds of unit test (logic unit test,
integration unit test, and frontend unit test) and see how the Spring TestContext framework and other
supporting tools and libraries can help in developing those test cases.
Instead of presenting the full details and list of classes that the Spring Framework provides in the
testing area, we will discuss the usage of the most commonly used patterns and the supporting
interfaces and classes within the Spring TestContext framework as we implement the sample test cases
in this chapter.
Implementing Logic Unit Test
As previously discussed, a logic unit test is the finest level of testing. The objective is to verify the behavior
of an individual class, with all the class's dependencies being "mocked" with expected behavior.
In this section, we will demonstrate a logic unit test by implementing the test cases for the
ContactController class, with the service layer being "mocked" with expected behavior.
To help mock the behavior of the service layer, we will use Mockito
(http://code.google.com/p/mockito), which is a popular mocking framework.
Adding Required Dependencies
First we need to add the dependency on Mockito into the project, as shown in Table 19-2.
Table 19-2. Maven Dependencies for Mockito
Group ID
Artifact ID
Version
Description
1.9.0
The core library of the Mockito mocking framework
org.mockito
mockito-core
Add the dependency in Table 19-2 to the project in STS.
Unit Testing Spring MVC Controller
In the contact web application we implemented in Chapter 17, Spring MVC was used as the presentation
layer. In the presentation layer, controller classes provide the integration between the user interface and
the service layer.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home