This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 979
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: 979
Is junit good enough for unit testing of servlets?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41035
    
  43
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 - my free Android networking tools app
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: 979
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: 41035
    
  43
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: 979
Thanks...for the inputs...

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unit testing framework for testing servlets
 
Similar Threads
Testing Server side code
unit testing JSP's and servlets: HttpUnit? Cactus?
Testing Server side java code
Is there any Unit testing framework for Andriod Code ?
How JUnit/JMeter Differ?