Play Games

Search This Blog

Wednesday, April 20, 2016

Error: Compile Error: Method does not exist or incorrect signature: Test.setMock(Type, someClassName)

I observed the above error in one of my friends developer org.
Problem: When he is saving some apex class,he is facing that issue.

That piece of code looks like this
@isTest
public class AnimalLocatorTest {
    @isTest static void testPostCallout() {
        Test.setMock(HttpCalloutMock.class, new AnimalLocatorMock());
        string s = AnimalLocator.getAnimalNameById(1);
    }
}
Solution: At first I was surprised.I didn't find any thing wrong in the code.Finally I observed that he has created one apex class with the name "test" which is creating this problem.So delete the apex class with the name "Test",then your issue is resolved.
Enjoy Coding...

4 comments:

  1. I had faced same issue. I had used System.Test.SetMock instead of Test.SetMock to solve this issue.

    ReplyDelete
  2. oh Thanks.We can resolve in the way you said.

    ReplyDelete
  3. Thank you Souvik, i tried your way, its working.

    ReplyDelete