Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit-testing servlets [closed]

I have a bunch of servlets running under the Tomcat servlet container. I would like to separate test code from production code, so I considered using a test framework. JUnit is nicely integrated into Eclipse, but I failed to make it run servlets using a running Tomcat server. Could you please recommend a unit testing framework that supports testing Tomcat servlets? Eclipse integration is nice but not necessary.

like image 568
Yuval F Avatar asked Sep 10 '08 06:09

Yuval F


1 Answers

Check out ServletUnit, which is part of HttpUnit. In a nutshell, ServletUnit provides a library of mocks and utilities you can use in ordinary JUnit tests to mock out a servlet container and other servlet-related objects like request and response objects. The link above contains examples.

like image 177
Scott Bale Avatar answered Oct 12 '22 23:10

Scott Bale