[ Team LiB ] |
7.16 Designing Testable JSPs7.16.1 ProblemDesigning JSPs to be testable outside of a running server. 7.16.2 SolutionWrite your JSPs to use helper classes that do not depend on a running server, and then test those helper classes with JUnit. 7.16.3 DiscussionTesting server code is challenging, as we have seen throughout this chapter. JSPs pose a greater risk of failure because multiple technologies are intermingled. JSPs mix snippets of Java code with snippets of HTML, XML, JSTL, and JavaBeans; add the deployment of JSP and the problems of testing only get worse. A better approach to designing and testing JSPs is to write support classes that do not depend on a running server to perform logic. These support classes can then be tested outside of a running server using JUnit. 7.16.4 See AlsoRecipe 7.15 discusses testing non-server-dependent classes. |
[ Team LiB ] |