In general, how would you unit-test Filter, Servlet and JSP?
- Use a mock library? (I searched for MockHttpServletRequest/Response and it seems each framework out there have their own version, is there any stand-alone HttpServlet mock lib?)
- How would you mock the HttpSession for authentication purposes? what is the usual workflow? would you need the web-container/server to be up and running?
- Is it usual that the unit-tests are run against a running DB? or the DB is also mocked? would the running DB be a bottle-neck on setup/teardown?
In the ideal world, I would love that the unit-tests run pretty fast without having to boot up the web server or database, but if that is something impossible, so be it.
Can anyone share their best practices and some of the issues stumbled upon unit-testing?
PS: If anyone has done TDD for a pure Java web-app (base library without the use of Spring/Struts etc), please share your experience as well.
I think I'll just lie down here for a second. And ponder this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop