I am studying JUnit and developed a simple class:
package com.test;
import javax.xml.bind.DatatypeConverter;
public class MyConverter {
public static byte[ ] base64ToByte( String s ) {
return DatatypeConverter.parseBase64Binary( s );
}
public static String byteToBase64( byte[ ] s ) {
return DatatypeConverter.printBase64Binary( s );
}
public static String byteToHex( byte[ ] s ) {
return DatatypeConverter.printHexBinary( s );
}
public static byte[ ] hexToByte( String s ) {
return DatatypeConverter.parseHexBinary( s );
}
}
But when I run my test cases, this is the results I got:
I noticed that if I call the class constructor, then I get 100% code coverage.
Is there a way to achieve 100% without calling a class constructor?
Should I declare a private constructor and change the class to have a singleton instance?