Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to increase my test coverage from 73% to 75% for Production. I am now increasing coverage on classes in Sandbox. I know how large are those classes without comments from Apex Classes page.

I'd like to know what is the size of the total project to be able to calculate how much do I need to improve coverage of a set of classes to be able to deploy a change set.

Deploying a change set and then validating to see how much the coverage improved is much too time consuming.

share|improve this question
Why not just check the code coverage in sandbox before deploying? – Ralph Callaway Feb 15 '13 at 16:50
Good strategy .Find out which is the biggest class and if that has 72% try improving to 100%.Don't concentrate on covering a single line.More the lines cover more your code coverage will be .As answered below Run All Test and see which class has maximum lines left to be covered – Mohith Shrivastava Feb 15 '13 at 16:53

Here is a blog post by Josh Birk which explains hows test coverage works.

You can refresh a sandbox from Production to have the latest code. Then navigate to Develop > Apex Class > Run All Tests The test results will show you the results of the test code coverage - i.e. the test coverage for classes and triggers, and which classes need coverage.

You can also run the tests via the IDE and the Developer Console.

When run via the Developer Console, if you click on the coverage, you can also see the lines that need test coverage highlighted in red.

Test Coverage when run via Developer Console

share|improve this answer
I understand how test coverage works, but I'd like to do be able to do some quick math instead of refreshing. – ipavlic Feb 16 '13 at 1:03
@ipavlic That is not massively clear in your question as you're talking about deploying via change set to figure out test coverage. You do not need to deploy to ascertain test coverage. – techtrekker Feb 16 '13 at 1:20
@ipavlic Unless you know how many lines code are currently covered & how many lines of code you'd be adding that haven't been tested to add to coverage, I'm not certain that you could even do what you're asking. In fact, if you add a line of code to existing code that's currently covered, that code will no longer be considered as covered until its been retested. As an example, assuming you had 400 lines of actual code with 70 % coverage, you'd have 280 lines of code currently covered. Add 50 lines of code and you'd be down to 62% or less coverage; lower if the code reduced existing coverage. – crmprogdev Feb 17 '13 at 17:11
@crmprogdev I do know how many lines are currently covered, and your calculations are exactly what I'd like to do. I'd like to know the actual project size to be able to guesstimate how much I could go up (or down) without having to poll Salesforce. My question is therefore "how can I find the total size of the project" instead of "how to test". – ipavlic Feb 18 '13 at 9:05
@ipavlic Then I suggest you edit your original post to reflect the exchange of comments above so those who view your post now will immediately grasp what you're seeking. Quite honestly though, I'm doubtful that you're going to find a response that's all that accurate for the reasons I mentioned above; particularly the placement of your new lines of code which could greatly reduce the current code coverage. BTW, I assume you probably know that if you run your tests in the Developer Console, it will tell you exactly how many lines of code are executed. – crmprogdev Feb 18 '13 at 15:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.