Test Code Coverage of Salesforce Org in Different Ways

Screen Shot 2018-12-28 at 6.55.06 PM

Some times we not noticed and leaves about do we really have complete 75% Code coverage in our salesforce org. To improve code coverage first we need to know the coverage report class by class. For that we have multiple ways to find out.

Here are few for you……

Using ASIDE.IO 

1. Login to ASIDE.IO as shown as below image by selecting type of the login

2. Click on Test tab right side and next Code Coverage

Screen Shot 2018-12-28 at 6.51.13 PM.png

3. It will show you a report with Overall coverage and calss by calss. And we can download in Csv Format.Screen Shot 2018-12-28 at 6.51.03 PM.png

 

Use App exchange Product: Lightside Power Tools

Easily view the Code Coverage of your Apex Classes and Triggers; what test classes are contributing to their coverage and how they are impacting the full Org Code Coverage.

This App Exchange Product not only useful for Code coverage report but also for

  • Enhanced Deployment: Enables Change Sets to be rapidly created and deployed to multiple environments at the same time.
  • Script Library: Store Apex scripts and run them at your convenience or schedule them as required. Optionally store the Debug Logs results against the scripts.

Link:-

https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFoy9UAD

Use App exchange Product: Code Coverage Report

How To Configure This APP

You can check the Setup step in Installation and Configuration Tab

Step 1:- Setup Remote Site Setting

Add a value for Remote site setting (In same org in which package is installed)

Goto Setup > Administration Setup > Security Controls > Remote Site Settings Add value to your Salesforce instance, for example  ‘https://na34.salesforce.com’

Step 2 Setup Base URL

Please set your Base URL.

Go to Setup > Develop > Custom Settings > Code Coverage Configuration > Manage > New. Set the name to ‘baseUrl’ and the value to your Salesforce instance, for example ‘https://ap2.salesforce.com’

 Open Custom Setting and Click on Code Coverage Configuration

 Then click on Manage

 Then click on Manage and then New Button and then Enter the below detail

Name as :- baseUrl

Value  as :- https://na34.salesforce.com

(Please enter your org base url.)

 

You Can find more information on

https://appexchange.salesforce.com/servlet/servlet.FileDownload?file=00P3000000Qq5GkEAJ

And Link:-

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

Use Developer Console or Tooling API(Work Bench)

Please follow the below steps every time you run the code coverage and you will have reliable coverage details.

Go to setup –> apex test execution —> click on Options —> uncheck the Store only aggregate code coverage option.
Go to Setup –> Apex test execution —-> View test history and Clear all test history
Go to Setup –> Apex classes —> Compile all classes
Go to Setup —> Apex test execution —> Run all test
After the run is completed, check the overall code coverage for your ORG by navigating to

Setup –> Apex classes –>Calculate Overall Code Coverage (or) on the Developer Console

If you are still not confident enough, you can use tooling API to determine the coverage.

We can use Tooling API  to calculate the coverage individually for an apex class/ apex trigger or overall 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”.

If you are still not confident enough, then you can do a production validation (click on validate only button in the tool which you are using to deploy) and it will give you errors/warnings if there is no coverage for classes.

Find KNOWLEDGE ARTICLE

https://help.salesforce.com/articleView?id=000199478&type=1

 

Thanks……

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s