Hi,
 
Thanks for your replies. Yes, shale-test works by itself, without any other dependencies.
 
Root cause of confusion was - source code for shale-test is not separately packaged in the nightly builds. I had to build whole shale framework for creating the shale-test.jar, and the ant build script had number of <get> tasks for downloading a bunch of other jars; making me assume that shale-test also requies those jars.
 
Can shale-test be used for testing custom JSF components as well?
 
Regards,
Arti
From: Murat Hazer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 24, 2006 4:06 PM
To: MyFaces Discussion
Subject: Re: Unit testing backing beans / custom components in JSF

We are using shale-test for unit testing JSF backing beans, shale is not invasive, you can use only this part of the shale without including other parts of it to build path.

regards....

On 5/24/06, David Friedman <[EMAIL PROTECTED]> wrote:
Arti,

> Shale provides mock objects, but it has dependency on
> Struts and Shale core, which we donot want.

Shale is under the Struts 'name' but should contain
no shared Struts code since it was written (supposedly)
to JSF, not Struts Action 1.X.  What do you know (or
think you know) that we don't?

Regards,
David

-----Original Message-----
From: arti [mailto:[EMAIL PROTECTED] ]
Sent: Wednesday, May 24, 2006 8:53 AM
To: MyFaces Discussion
Subject: RE: Unit testing backing beans / custom components in JSF


Hi,

Backing beans, I think, are slightly more than POJOs, since those are
JSF aware beans - which use JSf objects like FacesContext, Application,
VariableResolver etc. Unit testing these outside container, will require
stubs for such objects. Shale provides mock objects, but it has
dependency on Struts and Shale core, which we donot want.

Our application is pure MyFaces application. I am looking for a JSF test
framework for MyFaces only.

Same is true for testing custom component as well, since the components
and renderers also use FacesContext - e.g. save and restore state
methods / encode decode methods.

Regards,
Arti

-----Original Message-----
From: Aleksei Valikov [mailto: [EMAIL PROTECTED]]
Sent: Wednesday, May 24, 2006 11:30 AM
To: MyFaces Discussion
Subject: Re: Unit testing backing beans / custom components in JSF

Hi.

> How to unit test JSF code? Which test framework should be used for
> custom component/ backing beans unit testing?
>
> I am curious how do MyFaces developers (not users) test the various
> components in MyFaces/Tomahawk releases?

Backing beans are easy to test since they generally follow the IOC
pattern. Just instantiate the bean and inject whatever services/beans it
need via setters. We use Spring, so we often simply autowire backing
beans properties.
Testing scenarious for backing beans are quite simple:
1. Initialize the bean (and appropriate dependent beans).
2. Set properties.
3. Execute the action.
4. Check action outcome.
5. Check aposteriour values of properties.

As for the components, it's a bit more complex. From my point of view
there's two things you can/have to test: (a) if the component renders
itself as you want it to be rendered and (b) if what you want to be
rendered actually works.

Testing (a) is not a big problem. Instantiate a component, provide
mock/dummy ResponseWriter, render the component and simply check if the
rendered HTML (or
whatever) is allright. In some of my components I use testing framework
from Shale, it provides a couple of useful tools.

Testing (b) is much more complex. Okay, from my component I can generate
a pile of HTML/_javascript_/CSS, but I need to make sure that alltogether
this builds, for instance, a working DHTML menu which functions on
different browsers. I see no other possibility as manual testing here.

Bye.
/lexi






--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/

Reply via email to