I want to test a public method in which it calls another private method, I used the following reflection way to get the private method and tried to mock the return value of it, but it didn't work as the test stops at where the private call is. Any suggestions?
Method testMethod = handler.getClass().getDeclaredMethod("test", String.class)
testMethod.setAccessible(true)
testMethod.invoke(handler, "test string") >> true
The testMethod looks like the following:
private boolean test(String str) {
return true;
}