Monday 30 September 2013

EasyMock partial mock private methods

EasyMock partial mock private methods

I have the following scenario:
public class ClassA {
public void methodA(){
try {
int result=methodB();
} catch (IOException e) {
//Some code here
}
}
private int methodB() throws IOException{
//Some code here
return 1;
}
}
I want to cover the catch block of the public method methodA() in my test.
I don't want to change the visibility of the private method. Is there any
way to achieve partial mock of private method using EasyMock? Or is there
any way to change the behaviour of private method in my Junit class to
throw exception without using mocking?
Thanks in advance.

No comments:

Post a Comment