I am trying to mock my private method , but I am getting java.lang.IllegalArgumentException: object is not an instance of declaring class
.Below is my method
private String decodeResponse(byte bresp[])
{
String spresp = null;
//
return spresp;
}
Below is my test class ,
@PrepareForTest(MyClass.class)
@RunWith(PowerMockRunner.class)
public class MyClassTest{
@Test
public void test() throws Exception {
PowerMockito.spy(MyClass.class);
PowerMockito.doReturn("abcdefg").when(MyClass.class, "decodeResponse",Matchers.anyByte());
}
}
I am stuck in this issue for past 3 hours . Any help will be highly appreciable.
@PrepareForTest(MyClass.class)
@RunWith(PowerMockRunner.class)
public class MyClassTest{
@Test
public void test() throws Exception {
MyClass myClassSpy = PowerMockito.spy(MyClass.class);
PowerMockito.doReturn("abcdefg").when(myClassSpy, "decodeResponse",any(byte[].class));
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.