Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unit testing framework for testing servlets

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Which is the best framework for unit testing of servlets?

Regards
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not personally used Cactus , but am aware that its a good unit testing framework for testing server side code.

Cactus Homepage
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is junit good enough for unit testing of servlets?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eugene Abarquez
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks...for the inputs...

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic