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/v37.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.
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/v37.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.
No comments:
Post a Comment