公共最终静态字符串的测试类

时间:2016-04-29 11:07:23

标签: salesforce constants test-class

如何为salesforce中包含公共最终静态字符串的类编写测试类? 我尝试使用system.assertequals 似乎没有正常工作。

@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 个答案:

答案 0 :(得分:0)

在班上你需要标记变量@TestVisible。点击此处:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_testvisible.htm

@TestVisible private static Integer recordNumber = 1;