JUnit - Testing a method that in turn invokes a few more methods

Posted by stratwine on Stack Overflow See other posts from Stack Overflow or by stratwine
Published on 2010-05-21T20:53:09Z Indexed on 2010/05/21 21:20 UTC
Read the original article Hit count: 155

Filed under:
|

Hi,

This is my doubt on what we regard as a "unit" while unit-testing.

say I have a method like this,

public String myBigMethod()
      {
         String resultOne = moduleOneObject.someOperation(); 
         String resultTwo = moduleTwoObject.someOtherOperation(resultOne);
         return resultTwo;
      }

( I have unit-tests written for someOperation() and someOtherOperation() seperately )

and this myBigMethod() kinda integrates ModuleOne and ModuleTwo by using them as above,

then, is the method "myBigMethod()" still considered as a "unit" ?

Should I be writing a test for this "myBigMethod()" ?

Say I have written a test for myBigMethod()... If testSomeOperation() fails, it would also result in testMyBigMethod() to fail... Now testMyBigMethod()'s failure might show a not-so-correct-location of the bug.

One-Cause causing two tests to fail doesn't look so good to me. But donno if there's any better way...? Is there ?

Thanks !

© Stack Overflow or respective owner

Related posts about junit

Related posts about unit-testing