java - Using PowerMockito to mock method with void return-type: "invalid void parameter" -
i having trouble trying unit test java code @ point calls native methods. basically, trying use powermockito
mock class call native. able mock non-void methods fine, keep getting compilation errors when try mock method of void return type. here example of code i'm trying test:
public class classthatcallsnative { void initobject(bytebuffer param1, int param2) { //calls native } int getid(int param1) { //calls native } }
i have code in test class:
powermockito.when(mclassthatcallsnative.getid(mockit.anyint())).thenreturn(0);
this line of code compiles fine, following line compilation error:
powermockito.when(mclassthatcallsnative.initobject(mockit.any(bytebuffer.class), anyint())).donothing();
the error message says invalid void parameter , points .initobject. idea doing wrong?
for void methods, need use below one
powermockito.donothing().when(mclassthatcallsnative.initobject(mockit.any(bytebuffer.class), anyint()))
Comments
Post a Comment