0

We have a test class, and it has @isTest and for some reason, salesforce is showing this class as needing coverage? Shouldn't this class be excluded from code coverage?

@isTest(seeAllData=false)
global class MyMockResponse implements HttpCalloutMock{
    global HTTPResponse respond(HTTPRequest request) {
         //some code
    }    
}
2

It doesn't need coverage if it is annotated with @IsTest. Any report to the contrary is in error. Note however that you shouldn't be using global.

| improve this answer | |
  • Global should be fine, HttpCalloutMock interface can be either global or public. – sunil gupta Sep 24 at 21:11
  • 1
    Just because it doesn't break anything doesn't mean you should use it. – Adrian Larson Sep 24 at 21:13
0

This seems like a bug in salesforce... The following post had the resolution. Why are my Test Classes (marked @isTest) getting listed with Code Coverage?

 1. Copy the listed test class and paste into notepad.
 2. Delete the listed test class.
 3. Create new test class with **same class name** and **same body**(structure).
 4. Finally Run the test class.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.