You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by lightbulb432 <ve...@hotmail.com> on 2006/12/12 08:19:52 UTC

Testing JSF applications

How would you go about testing a JSF application? Would you test both the
session beans and the HTML output (using HttpUnit and/or HtmlUnit) from the
JSF pages, or just one or the other?

I ask because it seems like the session beans and HTML output tests might be
testing for roughly the same things (because the session beans expose
functionality used to create the HTML), so wouldn't there be redundancy in
the tests? Or is that a good thing?

What are best practices in this regard?
-- 
View this message in context: http://www.nabble.com/Testing-JSF-applications-tf2805952.html#a7828514
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Testing JSF applications

Posted by Jeff Bischoff <jb...@klkurz.com>.
lightbulb432 wrote:
> So would somebody using Selenium not test their session beans separately,
> because their correctness is being indirectly tested by testing the web
> output?

When it breaks, won't you want to know which layer has problems? :)



Re: Testing JSF applications

Posted by Paul Spencer <pa...@apache.org>.
The short answer to "Selenium seems like an alternative for HttpUnit or HtmlUnit"
is a yes.

Without going into a long discussion, I have a Maven project
containing all the business logic.  That project contains
the appropriate tests.  The user interface project, using MyFaces in
this case, only test the UI, not the business logic.

The MyFaces project does include some Shale[1] and Selenium based testing. Shale
based testing is very similar to jUnit testing and can be used
to test manage beans. It can be include in the Maven build process.  Selenium
requires user interaction in the testing process.  Their are services, like
HostedQA [2], the can run a Selenium test as a part of the Maven build process.

FYI: If you choose to use Selenium, I strongly suggest using the id attribute on
any tag being test.  This will make the test less brittle and more reliable.

Paul Spencer

[1] http://shale.apache.org/shale-test/index.html
[2] http://www.hostedqa.com/

lightbulb432 wrote:
> Thanks for those resources on Selenium, I'm going to look into it.
> 
> Selenium seems like an alternative for HttpUnit or HtmlUnit, am I right? If
> so, I'm still confused about whether to test the HTML output in addition to
> the session beans, or whether testing any one of the two will do. I ask
> because generally the HTML output is generated from the interface published
> by the session beans.
> 
> So would somebody using Selenium not test their session beans separately,
> because their correctness is being indirectly tested by testing the web
> output?


Re: Testing JSF applications

Posted by lightbulb432 <ve...@hotmail.com>.
Thanks for those resources on Selenium, I'm going to look into it.

Selenium seems like an alternative for HttpUnit or HtmlUnit, am I right? If
so, I'm still confused about whether to test the HTML output in addition to
the session beans, or whether testing any one of the two will do. I ask
because generally the HTML output is generated from the interface published
by the session beans.

So would somebody using Selenium not test their session beans separately,
because their correctness is being indirectly tested by testing the web
output?
-- 
View this message in context: http://www.nabble.com/Testing-JSF-applications-tf2805952.html#a7835259
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Testing JSF applications

Posted by Paul Spencer <pa...@apache.org>.
Below are some resources.
   http://myfaces.apache.org/tomahawk/testing/selenium.html
   http://wiki.apache.org/myfaces/Automated_Testing

You can also see the Selenium based test used to test MyFaces and
Tomahawk components.
   http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/test/selenium/

To run the test:
o Checkout the source
o cd to tomahawk/example/simple
o execute the command
    mvn package cargo:start -P Selemium
 From more information see http://myfaces.apache.org/tomahawk/testing/selenium.html

Paul Spencer


lightbulb432 wrote:
> How would you go about testing a JSF application? Would you test both the
> session beans and the HTML output (using HttpUnit and/or HtmlUnit) from the
> JSF pages, or just one or the other?
> 
> I ask because it seems like the session beans and HTML output tests might be
> testing for roughly the same things (because the session beans expose
> functionality used to create the HTML), so wouldn't there be redundancy in
> the tests? Or is that a good thing?
> 
> What are best practices in this regard?


Re: Testing JSF applications

Posted by Paul Spencer <pa...@apache.org>.
Maven has the concept of an attached test[1].  See the following
thread [2].  This can be useful when jUnit testing the business logic
then testing the session bean with Shale.

This will not help with Selenium based test, unless your test generates
the Selenium test scripts.

I am sure their are integrated framework in the market place, I have
not used any of them.

Paul Spencer

[1] http://maven.apache.org/guides/mini/guide-attached-tests.html
[2] http://www.mail-archive.com/users@maven.apache.org/msg46848.html

lightbulb432 wrote:
> If I need to test both business logic and presentation logic, is there some
> kind of framework that integrates both types of testing so that they are not
> done independently (and therefore tests do not introduce redundant code).
> 
> An example of what I mean is a session bean method that returns the email
> address of a given user. You would write a test to test this business logic
> (i.e. correct email address returned for that user)
> 
> Now when you test the web page that uses this session bean method to display
> the email address, you're essentially testing the exact same thing,
> duplication test code, increasing the difficulty of maintenance.
> 
> Is there some kind of integrated framework out there for testing that solves
> this problem? (e.g. Specify tests in a centralized place, such as an XML
> file, then both the presentation and business logic use that test?)
> 
> Does any of this even make sense? :)
> 
> Thanks.
> 
> 
> 
> lightbulb432 wrote:
>> How would you go about testing a JSF application? Would you test both the
>> session beans and the HTML output (using HttpUnit and/or HtmlUnit) from
>> the JSF pages, or just one or the other?
>>
>> I ask because it seems like the session beans and HTML output tests might
>> be testing for roughly the same things (because the session beans expose
>> functionality used to create the HTML), so wouldn't there be redundancy in
>> the tests? Or is that a good thing?
>>
>> What are best practices in this regard?
>>
> 


Re: Testing JSF applications

Posted by lightbulb432 <ve...@hotmail.com>.
If I need to test both business logic and presentation logic, is there some
kind of framework that integrates both types of testing so that they are not
done independently (and therefore tests do not introduce redundant code).

An example of what I mean is a session bean method that returns the email
address of a given user. You would write a test to test this business logic
(i.e. correct email address returned for that user)

Now when you test the web page that uses this session bean method to display
the email address, you're essentially testing the exact same thing,
duplication test code, increasing the difficulty of maintenance.

Is there some kind of integrated framework out there for testing that solves
this problem? (e.g. Specify tests in a centralized place, such as an XML
file, then both the presentation and business logic use that test?)

Does any of this even make sense? :)

Thanks.



lightbulb432 wrote:
> 
> How would you go about testing a JSF application? Would you test both the
> session beans and the HTML output (using HttpUnit and/or HtmlUnit) from
> the JSF pages, or just one or the other?
> 
> I ask because it seems like the session beans and HTML output tests might
> be testing for roughly the same things (because the session beans expose
> functionality used to create the HTML), so wouldn't there be redundancy in
> the tests? Or is that a good thing?
> 
> What are best practices in this regard?
> 

-- 
View this message in context: http://www.nabble.com/Testing-JSF-applications-tf2805952.html#a7840442
Sent from the MyFaces - Users mailing list archive at Nabble.com.