On 7/19/06, Sreedevi Aswath <[EMAIL PROTECTED]> wrote:

Hi,

   I would like to know if  HtmlUnit or HttpUnit can be used to write unit
tests for JSF application.
   Do HttpUnit or HtmlUnit require a web container to run the unit tests.
   Shale supports HtmlUnit, as given in the night build.

Thanks,
Sreedevi


HtmlUnit (and HttpUnit) can be used to write tests for a JSF application,
but they presume that the application has actually been deployed in a
container -- what you are testing is the actual deployed app, so I tend to
call these tests "system integration" tests rather than "unit tests".

For examples of how to build such tests, download the shale-usecases zip or
tar.gz file from the nightly builds, and examine the contents of the
src/test/java directory -- particularly the
org.apache.shale.usecases.systest package.  These tests use Cargo to
automatically deploy the application to a configured Tomcat instance, then
use HtmlUnit to perform the actual tests, and examine the results by looking
at the DOM tree of HTML elements that were rendered.  You can easily set up
similar tests for your own application by using the same approach.

However, I would also encourage you to write separate unit tests for your
backing beans, which can be executed without a container (and without
HtmlUnit).  The src/test/java directory of the use cases example contains
many examples of this kind of unit testing as well.

Craig

Reply via email to