function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CarlBCarlB 

Unit test reporting "Method does not exist" in Eclipse

Hello.

I have a set of Apex classes which have unit tests.  The classes all save ok, but if I try to run the unit tests from within Eclipse, I get back "Method does not exist or incorrect signature".  However, if I run the unit tests from Salesforce, it all works ok.

Any ideas?

Thanks,

Carl
sandeep sankhlasandeep sankhla
Hi CarIB,

It means you dont have latest code in your eclipse..may b..you can take refersh from server for entire project and then check if same error is coming ...if it is coming means you have error in your some class and you will be able to see the error ...

Can you share the entire error messgae here so I can tell you in which class you are getting error...also when you run the class from org that time also may b some classes are failing..so you can do run test from developer console and check if is there any class which is failing...

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 
CarlBCarlB
Hello.

Thanks for the reply.

I decided to create a completely new Eclipse project for my org, so that I would be sure that I had the latest code.  I did this and ran the run tests again and still got the same error.

Running the unit tests from the developer console works fine, so it is something to do with how Eclipse is running the unit tests.

Regards,

Carl
 
sandeep sankhlasandeep sankhla
Hi CarIB,

If you have latest code in eclipse then it should not fail if it is not failing in developer console..

Can you try to run all the classes from developer console and share a screen shot of that run if that not fails..

Thanks,
Sandeep
CarlBCarlB
Hi.

Basically my code looks like this:
 
interface A {

    String getA();

}

interface B {

}


B b = ...

b.getA();
Everything saves ok, and running unit tests in the developer console works ok, but running unit tests from Eclipse throws an error at "b.getA()", saying that method "getA()" does not exist.

However, if I add the method to interface B, it works from Eclipse.

Carl

 
sandeep sankhlasandeep sankhla
Hi CarlB,

Because you are creating instance of b and using it from b as b.getA();, but it was related to A interface so you should do like 

A a = ....
a.getA();

Then it will work for you in this case..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 
CarlBCarlB
Hi,

Sorry, the code sample above was wrong, it should say "interface B extends A {...}"

Carl