Thanks,

I agree with you, before integration tests i need to write unit test,so i am looking for answer of "How can i do write correct unit tests for backing beans which use spring and hibernate?". I understand following points from your asnwers, if i am wrong please correct me;
1- to write correct unit tests i should isolate the uni t(class/function) which is under test from other layers/api's.
2- to test jsf backing bean shale-test framework is a good choice.
3- i should use jmock (or equivalent) to create mock objects of spring managed services and dao's then i should set these mocks to the backing bean in the test setUp() metod.

I am a little confused beacuse i couldn't find any good article, tutorial or sample code for a scanerio like this. I need to find something to get a clear understanding. Any suggestions?

Another question; can i use canoo web tests (or selenium) for integration tests? Is this a correct approach or should i follow a different way for integration testing?

best regards....

On 5/15/06, Adam Brod <[EMAIL PROTECTED]> wrote:

Hi Murat-

I agree with what Dave B. said - Unit Testing is very different from Integration Testing.  I have found that it is best to start with Unit Testing where you are testing an individual method or class (a unit) in isolation from all other objects.  Therefore, you should mock/stub out the other frameworks and classes that are used by the backing bean you are testing.

Once you have good unit testing coverage and know that your backing bean does what you want it to, then you can build larger Integration Tests that test the interactions between the backing bean and the hibernate daos.  If you start with Integration Testing, it is much more difficult to isolate bugs in your code because for any given test, there is lots of code being executed.

I hope this helps,

Adam Brod

Product Development Team


"Murat Hazer" <[EMAIL PROTECTED]>

05/14/2006 08:11 AM

Please respond to
"MyFaces Discussion" <[email protected]>

To
"MyFaces Discussion" <[email protected]>
cc

Subject
JSF Backing Bean Unit Testing







Hi,

I am trying to write unit tests on my backing beans' action, actionListener and other methods, and using shale-test framework to accomplish this. From TDD principles i know every unit test should test only itself not other functions or layers etc., but in my scenario backing beans use spring managed services and these services also use hibernate managed DAOs, and also these backing beans use other request or session based beans. What are the best practices about unit testing backing beans like this?

Should i also use mock objects (like jmock or easymock) for these properties of the backing beans? And what should i do to validate faces-config files? I study appfuse (on backing bean tests exceutes all layer functions..) and examples come with shale, they are not very clear (or my misunderstaning), i think i need a clear and nice sample (also other users) unit test on a such complicated backing bean)

regards...
--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Disclaimer: This electronic mail and any attachments are confidential and may be privileged. If you are not the intended recipient, please notify the sender immediately by replying to this email, and destroy all copies of this email and any attachments. Thank you.





--
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