Skip Links

Network World

IT Asked & Answered

AdviceGadgetsToolsITAA Home

Tools for testing JSP pages?

What tools are available to perform unit testing on JSP pages. I'd like to find something

similar to the JUnit tools that are used for unit testing Java classes.

Blass
Answer by Steve Blass

Expert's answer

There are a variety of JSP testing tool options out there. Depending on the specifics of how your application is implemented you will find some are more appropriate and easier to use than others. If your JSP pages use custom tag libraries to implement Java functionality you may be interested in TagUnit which is a tag library for testing custom tags within JSP pages. For testing server-side Java code generally the Cactus framework from Apache can be used and the Cactus site provides instructions for JSP testing in your actual servlet container. JunitEE provides a Junit test runner capable of working with servlets. There is a forum discussion comparing and contrasting Cactus and JUnitEE online at Java Ranch. Commercial options include JTest from ParaSoft and Java Unit Test from AppPerfect. JWebUnit is another testing framework that works together with JUnit to test server side software. Mockrunner works with Junit to test against mock objects without calling the real server infrastructure. HttpUnit is a testing tool designed for black-box testing of web sites which can be used to test against the web responses of your JSPs and servlets and the HttpUnit site also provides a ServletUnit tool for testing servlets in a simulated container. For Struts applications the
StrutsTestCase for JUnit toolset provides both mock object testing and the ability to use Cactus to actually run the Struts ActionServlet to execute your tests. You can find a long list of open source testing tools including those mentioned above and others at
opensourcetesting.org. The wide variety of tools and techniques available stems from the fact that JSP testing is more complicated than client side software unit testing. You will have to review your implementation against the strengths of the various tools to choose the one that is right for you and you should expect to invest a bit of time and effort in to getting things set up and running just the way you want.