I'm trying to mock a private method using JMockit, and struggling. I have been working through the tutorials and can mock private methods that return values nut not without. This particular method interacts with a database and does not return anything. For the purposes of this test all I want to do is effectively mask this method out. The test format I am using is shown below, note that usually the result would be straight after the method deencapsulation is invoked.
@Test
public void testRetrieveAndSaveReport() {
//Make class with private class final, to be used in the Exceptionsinners class
final ESReportOutputLogic eSReportOutputLogic = new ESReportOutputLogic();
// Define Expectations
// pass eSReportOutputLogic as argument to make it a Mocked type in the Exceptions Class
new Expectations(eSReportOutputLogic){
ESReportOutputLogic eSReportOutputLogic;
{
Deepcapsulation.invoke(eSReportOutputLogic);
}
};
ESReportOutputLogic rol = new ESReportOutputLogic();
rol.retrieveAndSaveReport("","",1);
// asserts.....
}