aspose file tools*
The moose likes Servlets and the fly likes Unit testing framework for testing servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unit testing framework for testing servlets" Watch "Unit testing framework for testing servlets" New topic
Author

Unit testing framework for testing servlets

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
hi,

Which is the best framework for unit testing of servlets?

Regards
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
I have not personally used Cactus , but am aware that its a good unit testing framework for testing server side code.

Cactus Homepage


Rahul Bhattacharjee
LinkedIn - Blog
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
Is junit good enough for unit testing of servlets?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
JUnit would probably be involved in one form or other.

One possibility is to use a web testing framework like jWebUnit (which tests against a running web server/servlet container).

Another option is to test without a container, by using mock objects in lieu of the javax.servlet.(http.)* classes.


Ping & DNS - updated with new look and Ping home screen widget
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Originally posted by A Kumar:
Is junit good enough for unit testing of servlets?


No I believe not. Testing servlets is quite different from testing just plain Java classes as servlets needs to interact with the servlet container, and this is only possible while the container is running. Frameworks like Cactus (mentioned above) makes the job of testing servlets much easier.


There's so much to learn in this industry, and not everybody has the necessary interest.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
Another option is to test without a container, by using mock objects in lieu of the javax.servlet.(http.)* classes.


which framework do you suggest??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
Originally posted by A Kumar:
which framework do you suggest??


Mockobjects seems to be dead, but Mockrunner is still being updated.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

EasyMock is in active development too.

There are other options like HttpUnit (also based on JUnit, I believe)
I'm not sure if OpenSTA is still active, but we once used it to provide simple record/playback tests
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

EasyMock is in active development too.

There are other options like HttpUnit (also based on JUnit, I believe)
I'm not sure if OpenSTA is still active, but we once used it to provide simple record/playback tests
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 978
Thanks...for the inputs...

I have downloaded Easymock and am having a look at it...

 
jQuery in Action, 2nd edition
 
subject: Unit testing framework for testing servlets
 
Similar Threads
Testing Server side code
Is there any Unit testing framework for Andriod Code ?
Testing Server side java code
How JUnit/JMeter Differ?
unit testing JSP's and servlets: HttpUnit? Cactus?