You need to sign in to do that
Don't have an account?
Quddus Ololade 4
Test Class Cover for Constant Class in Salesforce
Below is the sample code :
I tried with assert and defining a constructor as well but it didnt work. The first line which is an integer is getting covered though but not the other lines
Test Class:
Any help appreciated.
public class ApexConstantsCls { public static final INTEGER DEFAULT_SIZE= 3; public static final STRING INITIAL_SUBMIT= 'Draft'; public static final STRING ERROR_MESSAGE = 'An error has occurred, please contact Admin.'; }
I tried with assert and defining a constructor as well but it didnt work. The first line which is an integer is getting covered though but not the other lines
Test Class:
@istest public class testtt { static TestMethod void Product2Extension_UnitTest1(){ Test.startTest(); System.assertEquals(ApexConstantsCls.INITIAL_SUBMIT,'Draft'); test.stopTest(); } }
Any help appreciated.
I will recommend you to start using trailhead to learn about test classes
1) https://trailhead.salesforce.com/modules/apex_testing
Pleasse check below post sample test class
1) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Also please check below post
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_example.htm
Sample Test Class for you
Try below code
Let us know if this will help you