On 5/14/06, Murat Hazer <mura...@gmail.com> wrote:
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?
For the third scenario (need access to other request and session scope
beans) you can populate the attributes on the MockHttpServletRequest and
MockHttpSession instances. I do this in the setUp() method of my unit
tests.
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...
Craig