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
SalesforceCrm AccountCRMSalesforceCrm AccountCRM 

Overall Code Coverage is Displaying Constant Value in Production as 74%

Can any one help me out with this ?The overall code coverage is displaying  a constant value in production as 74% only, i have written and modiifed 'n' no of test classes and deployed ,but still it displays the constant value.Any suggestion or alternatives where i can get the code coverage increased and can do a deployment successfully.
Richard Jimenez 9Richard Jimenez 9
Hi,

Run ALL the tests in production, this will calculate the coverage against each class and the overall coverage. Use the deveper console to view all the class running and the class coverage. Look for your classes (ignore any that are part of of a managed package). If you double click on a class in the 'Overall Code Coverage' panel it will show you what lines are covered.

Thanks,
Richard.
Amit Chaudhary 8Amit Chaudhary 8
You can try below app exchange product. I hope that will help you

Code Coverage Report
https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000DXzlpEAD

Now you can view the overall and individual entity code coverage in your organization. The results of the code coverage can be downloaded in Excel format

Click on Run All Test and use above app to see each class code coverage in production

How to configure the App. 
Please check below link for same
1) http://amitsalesforce.blogspot.com/search/label/App%20Exchange

Let us know if this will help you
 
Chinna99Chinna99
By using workbench please follow below steps to get accurate test class coverage.

1) How many lines are covered for a specific class or trigger: 

SELECT NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverage WHERE ApexClassOrTriggerId = 

2) Which lines are covered for a specific class or trigger: 

SELECT Coverage FROM ApexCodeCoverage WHERE ApexClassOrTriggerId = 

3) The current org-wide coverage: 

SELECT PercentCovered FROM ApexOrgWideCoverage 

To test these queries you may use Workbench (workbench.developerforce.com) as follows: 1) Go to Utilities | REST Explorer 2) Select GET 3) Enter the following URL: 

/services/data/v29.0/tooling/query/?q=YOUR_QUERY 

where YOUR_QUERY should be the query to execute

4) Click "Show Raw Response". 
Ravi Dutt SharmaRavi Dutt Sharma
Hey, 

You can try below steps. Let me know if it works.

1) In the Developer console run this Tooling API query 
SELECT Id, ApexClassOrTriggerId, ApexClassOrTrigger.Name, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate 

2) Select all results and hit delete 

3) Run all tests 

4) Check Setup/Apex classes/Code coverage now.
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Richard Jimenez 9,@Amit Chaudhary 8,@Chinna1987,@Ravi Dutt Sharma :Thanks For your response.
@Richard Jimenez 9 :As Suggested ,im doing it  but the code coverage remains constant.
@Chinna1987 :I tried querying in workbench ,but the overall code coverage is displaying when i use the percent query but when i use
1) How many lines are covered for a specific class or trigger: 

SELECT NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverage WHERE ApexClassOrTriggerId = 

2) Which lines are covered for a specific class or trigger: 

SELECT Coverage FROM ApexCodeCoverage WHERE ApexClassOrTriggerId =
this queries in workbench by giving the class id or trigger id the system throws an error as :Malformed Query

@@Ravi Dutt Sharma :As Suggested ,i have used the query in the query editior before deleting the results, it displayed the same value .Again i selected and deleted all the result .I reran all the test classes again ,now the code coverage was displaying as 78% , but when i tried to deploy the code it throwed the error as Code Coverage is low.

Any Help very much appreciated.
 
Ravi Dutt SharmaRavi Dutt Sharma
Hi,

So you mean to say the current coverage on your production instance is 78% and when you deploy the new code, the coverage goes down? This means that due to the current code which is getting deployed, the coverage is falling below 75%. Can you tell me how much coverage you have in your sandbox from which you are deploying the code?
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ravi Dutt Sharma :The Overall Code Coverage in Production is displaying as 81% and in Sandbox its displaying as 77%.From Sandbox i need to move modified codes 3 triggers and a class with their test classes.I tried again deploying but the system throws the code coverage error.Any Suggestion please.

PFA Screen Shot In Sandbox OverAll Code Coverage :
SANDBOX
Overall Sandbox
PFA Screen Shot In Production OverAll Code Coverage :
Workbench
Prod OCC
Ravi Dutt SharmaRavi Dutt Sharma
How much coverage does the 3 triggers and a class have that you are deploying? It may be that the coverge of these triggers and class is very low because of which the overall coverage is going below 75%. 
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ravi Dutt Sharma :The triggers and class have  (trigger1 - 80 , trigger2- 85 , trigger - 78 and class has - 85).one of the trigger1 had around 90%  but when i uncommented two lines the value got reduced to 67% so will this effect ,while deploying.
deploy triggers sololy.Any alternatives.
Ravi Dutt SharmaRavi Dutt Sharma
I suspect you might be using seeAllData=true in your test classes due to which the coverage is getting reduced when you deploy it on Prod. Is that the case?
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ravi Dutt Sharma :Hey for the triggers nd classes which has test class does not have the SeeAllDats=true ,but for few of the test class which is been deployed has that SeeAllData= true, so will it effect the currently moving test classes.
Ravi Dutt SharmaRavi Dutt Sharma
No that will not effect the exisitng classes. Can you check the debug logs in production which gets generated when you are deploying the code
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ravi Dutt Sharma :Its Strange .I tried deploying sololy the class and test class (>75% Code Coverage),but still the system throws an error as code coverage.
User-added imageUser-added image
 
Ravi Dutt SharmaRavi Dutt Sharma
Can you check the debug logs please. Without debug logs, its very difficult to guess the root cause
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ravi Dutt Sharma :Debug log:User-added image
SalesforceCrm AccountCRMSalesforceCrm AccountCRM
@Ravi Dutt Sharma:PFA Debug log