Thursday, February 20, 2020

Code Coverage

Hey TrailBlazers!


One interesting area within any Salesforce org is code coverage.Inhereting an environment with low code coverage is never easy.

So the official statement : 

Code coverage indicates how many executable lines of code in your classes and triggers have been exercised by test methods. ... To deploy Apex or package it for the Salesforce AppExchange, unit tests must cover at least 75% of your Apex code, and those tests must pass.

...but how do you identify the root causes for your low coverage?



Select the Gear Icon >>Select Developer console




Once your developer console is open >>Select Query Editor >>




Paste the query below in the query editor  :

SELECT ApexClassorTrigger.Name, NumLinesCovered, NumLinesUncovered FROM ApexCodeCoverageAggregate ORDER BY NumLinesUncovered DESC LIMIT 10

Please ensure that you tick "Use Tooling API" and the execute:




This will give you a list of the top 10 classes lowering your code coverage.


Once identified its time to create the test classes.

Happy Trails!






Generate reports from Opportunities using a Visualforce Page in Salesforce

  Step 1: Create a Visualforce Page Go to the Setup menu in Salesforce. Search for "Visualforce Pages" in the Quick Find box and c...