No Test Coverage Issue in Salesforce


Some times we write Test Classes but not getting desired code coverage. We can try these steps. It can solve our problems.


Step 1

Ensure your test class declared with correct annotation,

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

Example:

  1. @isTest
  2. public class MyTestClass {
  3.    // Method for testing
  4.    static testMethod void test1() {
  5.       // Implement test code
  6.    }
  7. //or
  8.    @isTest 
  9.     static void test1() {
  10.       // Implement test code
  11.    }
  12. }



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











Comments