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
BDArnzBDArnz 

Average Test Coverage Error in Force.com IDE

I'm using Eclipse to develop Apex code.  I was working on a pretty big controller directly in my production account (I know, I know...) and got a little behind on implementing the test routines.  Eventually the controller would no longer save to my server since the average test coverage dropped below 75%.  I was seeing this error in the 'Problems' window in Eclipse:

 

'Average test coverage across all Apex Classes and Triggers is 74%, at least 75% test coverage is required'  

 

I immediately stopped working on the controller and went back to implement test routines in this and a couple of the other controllers.  Now the controller will save but the error message persists even if I run tests from within Eclipse.  When I run tests directly in the UI I'm told the average coverage is 84%.

 

How can I 'clear' the error message from the Eclipse 'Problems' window? 

Best Answer chosen by Admin (Salesforce Developers) 
jeffdonthemic2jeffdonthemic2

This happens frequently when the error messages get "stuck" in Eclipse. You should be able to close the project and then restart Eclipse and it should clear out.

 

In the worst case you can delete the project from Eclipse and then recreate it again.

 

HTH

 

Jeff Douglas

Appirio, Inc.

http://blog.jeffdouglas.com

All Answers

jeffdonthemic2jeffdonthemic2

This happens frequently when the error messages get "stuck" in Eclipse. You should be able to close the project and then restart Eclipse and it should clear out.

 

In the worst case you can delete the project from Eclipse and then recreate it again.

 

HTH

 

Jeff Douglas

Appirio, Inc.

http://blog.jeffdouglas.com

This was selected as the best answer
BDArnzBDArnz

I had already closed and reopened Eclipse many times but the error remained.

 

I hadn't thought of deleting the project and reloading.  That took care of it.

 

Quite a clumsy solution but it worked.  Thanks for your very quick reply.

Mike LeachMike Leach

I'm having the same problem with Eclipse 3.4.2 and v17 Force.com IDE.

 

91% test coverage in Salesforce, but stuck on 68% in IDE even after shutdown/restart. 

 

Do I really need to wipe out and reload the project? Ouch

JakesterJakester

I have a related question: my friend and I are doing some consulting work and have been given access to our customer's sandbox, but not their production environment. We wrote a unit test, but the only way I know to see what code coverage percentage is to deploy to production. Is there another way?

 

Thanks!

BDArnzBDArnz
I didn't find any other way to clear the discrepency.  It wasn't too bad and it had the side benefit of causing me to rethink my project structure.  I was working multiple projects but had all the classes, pages, etc loaded into a single project in Eclipse.  When I tried this I only loaded the ones for the problem project to make sure it worked.  It did.  I then created different project files for the other ones.  So in the end I cleared the error and cleaned up my organization...
BDArnzBDArnz
Are you using Eclipse for the development?  If so, you can run the tests from there even though you're connected to the sandbox.  That will give you an idea what your coverage is before you deploy.  Otherwise you could go ahead and deploy.  The tests run at that time and will fail if you don't have enough coverage.
Mike LeachMike Leach

I tried "Refresh to Server", "Save to Server", and "Synchronize"... none of which worked.

 

Deleting the project and re-importing is the only way to clear the error and resume work. 

 

I was consistently introducing an error in unit tests that called a controller method that returns a PageReference, however I didn't have an LValue to reference the return value (didn't think I needed it. Always returns null).

 

 

//Compiler throws ambiguous errormyController.PageEventHandler();//FixedPageReference ref = myController.PageEventHandler();

 

The compiler error was ambiguous. Something like "Could not save. Error on Line 1. Please check logs", so I would back out of recent changes by commenting lines and saving to understand what line of code introduced the error.

 

It is at this point that test coverage falls below 75% and starts warning. Adding a PageReference LValue to the test fixes the error, saves to server, and running tests in SForce indicate coverage is above 75%, however Eclipse stays stuck at < 75%.

 

I suppose incremental code/test is the way around this bug, but it sure cramps my style :-) I prefer to rapidly prototype in a Dev org without tests, then promote code to production if I'm happy with it.

demegdemeg

Similar problem here with eclipse 3.52 - code coverage results change each time I run all tests from the IDE. On top of that I get different tests failing just by restarting the IDE. Seems incredibly buggy. Code completion in Eclipse is pitiful as well.

 

Are there any other IDE's out there that work better for Force.com development, because this one stinks.