公共课A. {
[...]
private int methoda(int i)
{
...
methodb();
....
}
private void methodb()
{...}
[...]
}
试验:
@Test
@PrepareForTest({...})
public void testMethoda() throws Exception
{
//mytest
A a = PowerMockito.spy(new A());
Method privateMethod = a.getClass().getDeclaredMethod("methoda", int.class);
privateMethod.setAccessible(true);
PowerMockito.doNothing.when(a, "methodb");
..
}
例外: java.lang.NoSuchMethodException
谁能告诉我如何处理这种情况?