How do I verify whether printPreview.createShowReport();
is called. I can't even set the mock object because as soon as I call the method it instantiates to null and creates new object.
public void previewOrDirectPrint(File file, boolean val) {
try{
printPreview=null;
printPreview=new ExamReportPrintUI(this,file);
}
catch(Exception e){
e.printStackTrace();
}
if(!val)
{
printPreview.createShowReport();
}
else
{
printPreview.createHideReport();
printInitiate();
closeReportPreview();
}
here is my test case
@Test
public void testpreviewOrDirectPrint()
{
File file=new File("/Desktop/config/reportTemplate.html");
examReportManager.previewOrDirectPrint(file, false);
assertNotNull(Whitebox.getInternalState(examReportManager, "printPreview"));
}
Can anyone help me how to access the object or create mock and set to it. I can only verify if the object is mock.
I tried setting using Whitebox.setInternalstate("obj","",mockobject).
but both objects are different.