Must-readDevOps
Where the Metadata API deployment result keeps its errors and coverage warnings (opens in a new tab)
You will know which fields of the deployment result hold component errors, test failures and coverage warnings, and why a deployment can fail with an empty componentFailures list.
Why read this
The post also gives a checklist for diagnosing a failed deployment.
- Set includeDetails to true
- Check componentFailures
- Check runTestResult failures
- Check runTestResult codeCoverageWarnings
A failed Metadata API deployment often reports no component errors because the cause sits in another part of the result. The post explains the result layout, using Salesforce’s documentation. The overall outcome is in the DeployResult returned by checkDeployStatus(), but the detail is in its details field, which is only populated when includeDetails is set to true.
The details hold componentFailures and componentSuccesses, each a list of DeployMessage entries, plus runTestResult and retrieveResult where applicable. Each DeployMessage is typed as Warning or Error, a distinction that did not exist before API version 18.0, when every problem stopped the deployment. While a deployment is running, only componentFailures is filled in; the other fields appear after it finishes, so a mid-run check can show failures with no test results yet.
Test-side problems sit one level further down, in runTestResult. Failing tests are listed in its failures, and coverage problems in codeCoverageWarnings. A deployment can therefore fail with componentFailures empty and no test failing, for example when a class is not covered under a RunSpecifiedTests run. The post closes with a checklist: confirm includeDetails was set, check componentFailures, then check runTestResult failures and coverage warnings, make sure the deployment has finished, and compare the package’s classes with the classes the named tests cover.
The post also notes that the component lists moved from the deployment result into details, a change Salesforce says took effect in API version 29.0, so older scripts may look in the wrong place.
Read the original at dev.to (opens in a new tab)