The "Run All Tests" option in the Salesforce UI may not return accurate Organization-wide code coverage results. The only reliable way to obtain valid Org coverage is from a recent deployment using the Metadata API. This article explains how to retrieve accurate code coverage results from a deployment, whether it succeeded or failed, using SoapUI and Microsoft Excel.
To calculate accurate Salesforce Org code coverage, you must use a deployment's async response data, not the UI test runner. This process requires a recent deployment ID, the Metadata WSDL, SoapUI, and Microsoft Excel.
Navigate to the Deployment Status page in Setup and click your latest deployment. The asyncId appears in the URL as a query parameter — for example, asyncId=0AfD0000000uBQb. Copy this ID value.
In Setup, navigate to Develop > API (Classic) or Integrations > API (Lightning) and click Generate Metadata WSDL. Save the file with a .wsdl extension (change the file type to "All Files" and rename it metadata.wsdl).
checkDeployStatus request.asyncProcessId to your deployment ID and includeDetails to true.Id, Name, numLocations, and numLocationsNotCovered under the runTestResult node.numLocations) and note the last row number (for example, row 2342).=SUM(C2:C2342) to get total lines to cover.numLocationsNotCovered): =SUM(D2:D2342).=(1-(D2342/C2342))*100Note: This coverage result includes all Apex in the selected deployment, not just the target org's classes.
000386853

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.