jQuery in Action, 2nd edition*
The moose likes Testing and the fly likes Web unit testing, when main app to be tested is not running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Testing
Bookmark "Web unit testing, when main app to be tested is not running" Watch "Web unit testing, when main app to be tested is not running" New topic
Author

Web unit testing, when main app to be tested is not running

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
There are many options for doing unit testing of web application. Some of these tools are HttpUnit, HtmlUnit, Cactus, Canoo, JWebUnit, JMeter, Selenium and so forth.

My understanding is, all of these web unit testing tools require that the main web application (that is being tested) should be running, in order to be able to test the unit test written using HttpUnit, HtmlUnit etc.

Is my statement above true?

My goal would be to be able to run the unit test (written using HttpUnit, HtmlUnit etc.), even if the main web app were not running - similar to Junit that does not require any app to be running.

Is there any web unit testing tool that would allow to do unit test, even if the main app (that is being tested) were not running?

Sam
Gnanasekaran Sakthivel
Greenhorn

Joined: Jul 14, 2004
Posts: 23
When we run a JUnit test, JUnit really runs the code (java application in a sense) to test the code.
I do not know, but this is my opinion on HttpUnit. There is no way to test a web application without running the application in an app server. HttpUnit is testing User navigation functionality.

Best Wishes
Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
It depends greatly on the framework. For instance, it most modern action frameworks (Spring MVC, Struts 2, Stripes, etc) its very easy to unit test their building block pieces -- speaking in Struts 2 terms -- Actions, Interceptors, Converters are all very easily tested in isolation. With Struts 1 its much, much tougher... wouldn't say impossible, but probably not worth the effort.

If you're using jWebUnit or HttpUnit, you are NOT unit testing, nevermind the tools name. You are end-to-end, integration, acceptance testing.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Web unit testing, when main app to be tested is not running