Show failing tests after running a dry deployment (--checkonly) in Salesforce

Salesforce - SFDX CLI


Aug 24, 2021
featured image
      
sfdx force:source:deploy -x manifest/package.xml -l RunLocalTests --checkonly
      
    
      
*** Deploying with SOAP API ***
Deploy ID: 0Bf7D000003ygUYWBY
SOURCE PROGRESS | █████████████████████████████████░░░░░░░ | 92/111 Components

=== Component Failures [0]
Type  Name  Problem
────  ────  ───────


=== Test Results Summary
Passing: 30
Failing: 17
Total: 47
Time: 0
ERROR running force:source:deploy:  Deploy failed.
      
    
      
sfdx force:source:deploy:report -i 0Bf7D000003ygUYWBY  --json > deploy.log
      
    
Open deploy.log and look for the node "runTestResult" and then "failures". Example:
      
 "failures": [
          {
            "id": "01p0W000003fXQIQA2",
            "message": "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Validation Formula [THE COMPLETE ERROR HERE] ",
            "methodName": "myUnitTest",
            "name": "MyApexClass",
            },
            "packageName": "MyApexClass",
            "stackTrace": "MyApexClass myUnitTest: line 38, column 1",
            "time": "1927.0",
            "type": "Class"
          }, 
         {
               (...)
         }
    ]
      
    

Photo by Siora Photography on Unsplash


salesforce testing apex