I got this code in my junit:
new NonStrictExpectations(mPersonEvaluator) {
{
invoke(mPersonEvaluator, "doEvaluatePerson", withAny(String.class), withAny(Integer.class), withAny(Integer.class));
result = doEvaluatePerson((String)any, (Integer)any, (Integer)any);
}
};
I want to generate the result from my private method doEvaluatePerson((String)any, (Integer)any, (Integer)any);
everytime the method doEvaluatePerson is called in the business logic of mPersonEvaluator
.
The invoke works fine but the result is only calculated once during the setup of the junit
and that result is null.
My question is how can I declare such kind of usecase in jmockit
so that the mock uses my private method?
Thank in advance
Stefan
ok I found the answer.
one possible solution is to use a Delegator
like this:
result = new Delegate<PersonArt>() {
PersonArt delegator(String pShortName, Integer pOld, Integer pSize)
{
return doEvaluatePersonArt(pShortName, pOld, pSize);
}
};
works pretty fine.