2

I've been going around in circles all day try to do anything with the Force.com IDE. It keeps saying that my code coverage is 73%, but the Salesforce website says my code coverage is 78%. I've read that this is a known issue, which apparently no one is trying to resolve, and that a possible work around was to clear the test history in Salesforce. I did that and nothing happened. I'm trying to add more tests and publish them, but because it thinks the coverage is low it wont let them go through, so I'm just going around in circles where I can't do anything.

Is there any possible solution to this? I appreciate any help.

4
  • 1
    Are you working directly in production? You should build the tests in a sandbox and then deploy them to production. If you have coverage, everything should deploy. Jun 16, 2015 at 1:31
  • the IDE does not prevent you from deploying due to code coverage, SF does so not sure that sf coverage is showing 78% since simply deploying a test class alone will not drop code coverage. something more is going on here....
    – Eric
    Jun 16, 2015 at 2:20
  • DanielHoechst, yes it is production. This is an inherited instance where many other sloppy hands have had their way. Everything I've written (except for two files) has 100% coverage. Sadly, it's not enough because the other files do not because no one bothered to write any tests, and I don't feel like spelunking and guessing on making tests for it. Eric, prior to the 34 update last Friday I was able to publish updates fine, even while skirting the limit. All I did yesterday was add two string properties to a JSON deserializing class and it blew up...
    – Gup3rSuR4c
    Jun 16, 2015 at 15:24
  • So, I decided to delete an obsolete package we had. When I deleted it Salesforce.com said my coverage went up to 81%. Force.com IDE however said it dropped to 70%. The difference went from 5% to 11%... I'm at a loss on what to do...
    – Gup3rSuR4c
    Jun 16, 2015 at 22:02

1 Answer 1

1

There are some really good instructions for dealing with this sort of issue in Knowledge Article Number: 000213655 - Code coverage steps and considerations prior to deployments.

In particular, you should clear both the ApexCodeCoverage and the ApexCodeCoverageAggregate tables in the target org as a first step.

Compile errors or existing test cases that had @IsTest(SeeAllData=true) may have lowered the current code coverage in the production org below 70% prior to your deployment. These would need to be addressed first.

If the Eclipse IDE continues to give you issues you may be better to stage the deployment via a sandbox and change set as Daniel Hoechst commented. This would give you more direct feedback on the coverage in the sandbox before attempting the deployment to production.

Another alternative would be directly making the Metadata API deploy calls yourself, with a package.xml and source folders containing the changes.

4
  • 1
    Hmmm, well, I followed the instructions in the article and now both the IDE and website agree that it's 70%. For now I'm going to try and set up some more tests to increase the coverage and hope they get published. You mention @isTest (SeeAllData = true), which I do use on a few test methods. Does it negatively impact the coverage?
    – Gup3rSuR4c
    Jun 17, 2015 at 19:46
  • @Alex Adding more code coverage will pay off in the future. Especially if it makes useful assertions. The problem with @IsTest(SeeAllData=true) is that the tests become dependent on live data in the org. If that data is removed the tests could either start failing or not providing the expected code coverage. Best to avoid it whenever possible as it can cause issues in the future and makes the tests fragile. Jun 17, 2015 at 20:00
  • Gotcha. Well, for now I'll have to use it on the occasions that I do until I can get around to removing the legacy clutter and dependencies. For now I've managed to get to a percentage level that allows me to publish updates so I'll slowly try to bring up the code coverage. Sadly even at 100% coverage on everything I write I'll probably still be skirting the limit...
    – Gup3rSuR4c
    Jun 18, 2015 at 3:31
  • @Alex For what it is worth I've made an independent tool that shows both the size without comments and the coverage percentages for all the classes in an org. With this you can focus on the largest classes with the lowest coverage. Jun 18, 2015 at 4:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .