1

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');
    }

}
Pavel Slepiankou
  • 3,516
  • 2
  • 25
  • 30

1 Answers1

1

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;
raffters
  • 196
  • 4