How to return Array of Objects using Powermock and mockito -
i have method homecoming array of object.
public iconfigurationelement[] getconfigurationelementsfor(string extensionpointid);
i not sure how can mock phone call using mockito , powermock.
i have tried
mockconfigurationelements = (iconfigurationelement[]) mockito.anylistof( iconfigurationelement.class ).toarray();
but ending in classcastexception
.
mocking (stubbing) calls mockito done in next way (for example):
mockito.when(mockobject.getconfigurationelementsfor(mockito.anystring()).thenreturn(new iconfigurationelement[]{})
or
mockito.dorerturn(new iconfigurationelement[]{}).when(mockobject).getconfigurationelementsfor(mockito.anystring());
mockito.anylistof() utilize of matcher. matchers passed instead of real arguments when stubbing meaning behavior applied if method called arguments satisfying matchers.
mockito powermock
No comments:
Post a Comment