Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unit testing of web component - Lot of tools

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to learn about your experience on using the tools for writing unit test for web components.

What would be your suggestion for doing unit testing of web components for applications written using Struts 1 (running on WebSphere 5.1) and Struts 2 (running on WebSphere 6.1)?

There are a lot of choices for this. The names that stand out are:
1. HttpUnit
2. Spring's mock implementation for each key web interface e.g., MockHttpServletRequest, MockHttpServlet, MockHttpSession etc.
3. Cactus
4. HtmlUnit
5. Canoo
6. AppPerfect's free version that extends on JUnit and HttpUnit to create web based unit tests. http://www.appperfect.com/products/ut.pdf

There are many more listed under:
http://java-source.net/open-source/web-testing-tools

Again, the objective is to test web components. Junit is already in place.

With so many choices, it is difficult to settle down on one. Any of the above could be a feasible solution; as I am using Junit, Spring and have limited exposure to HttpUnit and Cactus.

But I wanted to learn about your experience on using tools for writing unit test for web components. Please share your thoughts.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My favorite is jWebUnit. It sits on top of HtmlUnit and gives it an easier-to-use (i.e., less code to write) and more powerful API.

HttpUnit operates on a lower level than HtmlUnit or jWebUnit (closer to HTTP than HTML - the name is appropriate), again meaning there's more code to write. Its JavaScript support is way behind HtmlUnit, and that's an area that's becoming ever more important.

Also check out Selenium. It can be used to create tests that can then be run either standalone, or from within jWebUnit. It's a very powerful tool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic