How to write testng testcase for private final anonymous inner class

49 views Asked by At
Public class Formatter{

private final SampleFormatter sampleFormatter = new SampleFormatter() {

@Override

public String formatDouble (int tag, double Value, int pre) { 

    if (Double.isNaN(Value)) {

    return "NaN";

} 

if (Value == 0.0D) {

return "0";

} 

else {

return df.format(Value);

}

}

@Override

public String formatBoolean(int i,boolean b){

return DEFAULT_FORMATTER.format boolean(i,b);

}
};
}

I'm writing unit testcases using testNg and Mockito.

Here how can I test the formatDouble and formatBoolean methods.

I want to test those methods also in my unit case to get the better coverage. Any Idea how to test private final anonymous inner class method?

0

There are 0 answers