java - Is it possible to use Mockito to completely stop a method from running? -


i'm unit testing method has lot of logic in it. goes this:

public void dosomething(int number){      //... complex logic      if (number % 2 == 0)        someinstanceobject.setodd(false);     else        someinstanceobject.setodd(true);       //... more complex logic , database connections } 

is possible mockito end method execution after if-else statement? reason why want because want test both conditions using mockito.verify(). want stop right away because after if-else blocks, there lot of stuff needs mocking database connections.

believe me, if can refactor this, put if-else statement in other utility class , expose public, would. turns out can't refactor code anymore.

i don't think possible stop after if using mockito. how mockito @ point want stop?

but can try dirty solution - mock method call succeedes if throw exception , in test method catch it. stop method execution , don't have mock db stuff.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -