I have this interface method:

isSomeConditionTrue();

my implementation is:

public boolean isSomeConditionTrue() {
        try {
                        if ( checkForCondition() ) return true;
       } catch (Exception e ) {
                          log.error("problem making the call");
      }
return false;
}


I am trying to test this implementation method using junit method
testing.
The problem is that the "log"  is actually avalon "Logger"  from
enableLogging method.

My unit TestCase, doesn't really know about any avalon stuff when I
do....
public void testIsSomeConditionTrue();

So when the exception occurs and caught, I get the NullPointerException
on "log", because I am not going through the full lifecycle methods and
hence have no log objects laying around. 

I  just want to test at method level without starting up the
container.      That I want to save for integration testing when I use
AbstractMerlinUnitTestCase.

I know probably I need to setup mock objects with my own   avalon Logger
passed into enableLogging lifecycle method(right?), but wondering how
are people dealing with this issue.

i.e. not having to setup a whole log of mock objects to test one
implementation method ?   there might not be any other option which is
fine in which case, I ask if there is a repository of Mock avalon/merlin
objects I can pull in to use.


thanks
Korosh.




Reply via email to