Thursday 29 October 2015

Code coverage or No test coverage issue in Salesforce

Some people's say, I have wrote test classes but not getting code coverage. In this occasion, try the below steps. It might solve your problem.

Step 1: 

Ensure your test class declared with correct annotation,

1. Test class should start with @isTest annotation.
2. Methods should declared as testMethod or @isTest annotation.


  1. @isTest
  2. private class MyTestClass {
  3.    // Methods for testing
  4.    static testMethod void test1() {
  5.       // Implement test code
  6.    }
  7.    @isTest static void test2() {
  8.       // Implement test code
  9.    }
  10. }

Step 2: 

Go to Setup --> Build --> Develop --> Apex Test Execution -->  Options --> Disable Parallel Apex Testing

Ensure "Disable Parallel Apex Testing" check box is checked.

Note: Try the below solution if you received an error as "UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record"

Step 3: 

Go to Setup --> Build --> Develop --> Apex Test Execution -->  View Test History--> Clear all data

Step 4:
Go to Setup --> Build -->  Develop --> Apex Test Execution -->  Select Test --> Run

No comments:

Post a Comment

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...