On 7/22/06, Sean Schofield <[EMAIL PROTECTED]> wrote:

IMO unit tests are much more useful then integration tests.  90% of
your problems can be detected with good unit tests.  I think one great
thing about JSF is that it makes your unit testing easier.  If you
combine JSF with the mock objects in shale-test you have a nice
solution.  You can even test component renderers this way.

Take a look at the unit tests for tree2 in the myfaces tomahawk
project.  I wrote a unit test for the renderer to make sure the tree
nodes were rendered in the correct order, etc.  That's the part that
you need to make sure is 100% accurate.  As for whether the tree comes
up at all and if it looks good, well that you can tell by loading up
the page and looking at it.


I don't disagree with Sean at all about the value of unit tests.  However,
for an application, I consider them "necessary but not sufficient".  No unit
test, for example, is likely to catch a configuration file syntax or
semantic error in a file that the unit tests don't process, but which might
very well cause the application to fail (when deployed) on first access.
Once you've had that happen to you in a demo -- very embarrassing! -- you
quickly learn to add integration tests as well.

Sean


Craig


On 7/20/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> 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