Find your content:

Search form

You are here

Why are code coverage results different in IDE and developer console?

 
Share

The Apex coverage results for unit tests in the Force.com IDE and the developer console are very different. I just ran 2 tests in both and got:

test 1
IDE: 75 lines not tests, 68% covered
Developer Console: 52% covered

test 2
IDE: 57 lines not tests, 76% covered
Developer Console: 57% covered

I'm wondering if this is because the developer console is counting blank lines differently (they show up highlighted in red). The IDE seems to have the correct number and I'm also wondering how to get the correct number from the developer console, which is much faster than the IDE for running my tests.


Attribution to: paul

Possible Suggestion/Solution #1

This is a known problem and MVPs like Jeff and Wes have good posts about the same. Here are links for reference:

http://th3silverlining.com/2011/11/30/salesforce-different-percentage-code-coverage-in-different-environments/

http://blog.jeffdouglas.com/2011/11/22/apex-test-coverage-does-not-match/

I think one way is to clear the Test execution history from "Setup > Develop > Apex test execution", and try again. Running all tests might help getting more accurate coverage after cleaning the stale results.


Attribution to: Abhinav Gupta
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4165

My Block Status

My Block Content