Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How t write JUnit Test Cases for my servlet

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I have a servlet and inside the doGet() method i have this
// Just checking username and password and authenticating them .



Please let me know how can i write Test Cases for this ??


Thanks in advance.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use HTTPUnit, HTMLUnit, Selenium etc.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like http://sourceforge.net/projects/junitee/ or http://jakarta.apache.org/cactus/ would let you run tests in a server environment.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you .

Now i understood that there a lot of them .

What to choose (The learning curve should be easy )

Any suggetions please
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd test the functionality outside of the servlet. I use servlets (well, not really, but their equivalent) only to marshall data to service objects (or similar). I keep functionality isolated from the Servlet spec as much as possible to make testing easier.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic