Test class for public final static string

1.8k Views Asked by At

How to write a test class for a class containing public final static strings in salesforce? I tried using system.assertequals Doesnt seem to work properly.

@isTest
private class Test_TPET_Constants{

    private static testMethod void test() {
        //TPET_Constants inst= new TPET_Constants();
        System.assertEquals(TPET_Constants.PICKLIST_COLLAB_SERVICE_SECURE_EMAIL,'Enterprise Secure Email');
        System.assertEquals(TPET_Constants.DRAFT_STATUS, 'Draft');
        System.assertEquals(TPET_Constants.ACTIVE_STATUS, 'Active');
        System.assertEquals(TPET_Constants.INACTIVE_STATUS, 'Inactive');
        System.assertEquals(TPET_Constants.SUBMITTED_STATUS, 'Submitted');
        System.assertEquals(TPET_Constants.REJECTED_STATUS , 'Rejected');
        System.assertEquals(TPET_Constants.PICKLIST_COLLAB_SERVICE , 'Collab Service');
        System.assertEquals(TPET_Constants.PENDING_IMPLEMENTATION_STATUS ,'Pending Implementation');
    }

}
1

There are 1 best solutions below

1
On

In your class you need to markthe variable @TestVisible. Check here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_testvisible.htm.

@TestVisible private static Integer recordNumber = 1;