Time for action – testing the product validator
Let's see how we can boot up our test context using the Spring Test Context framework to test our ProductValidator
class:
- Open
pom.xml
and you will findpom.xml
under the root directory of the project itself. - You will be able to see some tabs at the bottom of the
pom.xml
file; select the Dependencies tab and click on the Add button of the Dependencies section. - A Select Dependency window will appear; enter Group Id as
org.springframework
, Artifact Id asspring-test
, and Version as4.0.3.RELEASE
; then select Scope as test, click on the OK button, and savepom.xml
. - Now create an XML file called
test-DispatcherServlet-context.xml
under thecom.packt.webstore.validator
package in the source folder,src/test/resources ...
Get Spring MVC Beginner’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.