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:
- @isTest
- public class MyTestClass {
- // Method for testing
- static testMethod void test1() {
- // Implement test code
- }
- //or
- @isTest
- static void test1() {
- // Implement test code
- }
- }
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"
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
Post a Comment