Friday 10 February 2017

Salesforce Tutorial | How to learn Test class | Test Class Best Pratice | Sample Test class | Test Factory

Apex Unit Tests

In Salesforce , the code must have 75% code coverage to be deploy in Production. This code coverage is performed by the test classes. Please check below post to learn about test classes in salesforce :-

1) Apex Testing

Please check above Trailhead module to learn more about test classes.

2) Best Practice for Test classes | Sample Test class

Please check above post to see how to write test class for Trigger , Standard Controller , Controller and StandardSetController . With Test Class best practice. 

3) Test Utility Classes | TestDataFactory | Util Test in salesforce

Test utility classes contain reusable code for test data creation. Please check above post for How to create Test Data Factory in salesforce with example.

4) Test classes with @isTest

Please check above post for  @isTest annotation uses and Limitation.

5) StartTest and stopTest Method


StartTest and StopTest are standard test methods which are available for test classes. Please check above post for StartTest and StopTest Method uses and Limitation.  

6) Salesforce Testing Best Practice Guidelines | Unit Test Mechanism in Salesforce | Test Methods

Please check above post for Unit Test Mechanism in Salesforce and for Test class Best practice.

7) Code Coverage Report in excel Format | Test Class Result in XLS

Some time we need to Download/Export the code coverage for each class in excel file . So same we can use the Code Coverage Report App. Please check above post for same



8) @testSetup ( Set Up Test Data for an Entire Test Class )

Please check above post how to create test data for entire test class.




Amit Chaudhary


1 comment: