I have a class that only contains the definition of final strings. As everything is static and there are no methods, how can I test this code ?
public static myErrorClass{
public static final String ERROR_NO_FILE_SELECTED = system.label.NTProject_NoImportXMLFilesSelected;
public static final String ERROR_EMPTY_XML = system.label.NTProject_TheProjectCannotBeNull;
public static final String ERROR_INVALID_XML = system.label.NTProject_ImportFailed;
public static final String ERROR_FILESIZE_TOO_LARGE = system.label.NTProject_TheXMLFileIsTooLarge;
}
Attribution to: user8254
Possible Suggestion/Solution #1
Actually, I believe that salesforce is clever enough to know that this class doesn't require test code and it's not included in the code coverage calculation. This may however not show, and I have no official reference of this.
If you want to be absurdly thorough, you can do:
System.assertEquals(system.label.NTProject_NoImportXMLFilesSelected,
myErrorClass.ERROR_NO_FILE_SELECTED);
Besides code coverage you should also consider the functional aspects and to what extend that should be tested.
Attribution to: Samuel De Rycke
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34556