Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project deploy start --json missing information with failing tests #2952

Closed
WillieRuemmele opened this issue Jul 9, 2024 · 1 comment
Closed
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated

Comments

@WillieRuemmele
Copy link
Member

WillieRuemmele commented Jul 9, 2024

Summary

similar to #2757

when validating a deployment, test failures are not reported in --json output

sf project deploy validate -l RunSpecifiedTests -t  testtest12   --source-dir force-app  --json
 ›   Warning: @salesforce/cli update available from 2.45.6 to 2.48.6.
{
  "code": 1,
  "context": "DeployMetadataValidate",
  "commandName": "DeployMetadataValidate",
  "data": {
    "deployId": "0AfdL000004QTP3SAO"
  },
  "message": "Failed to validate the deployment (0AfdL000004QTP3SAO). Due To:\n",
  "name": "FailedValidationError",
  "status": 1,
  "stack": "FailedValidationError: Failed to validate the deployment (0AfdL000004QTP3SAO). Due To:\n\n    at Messages.createError (/Users/shivanshu.tiwari/.local/share/sf/client/2.45.6-

whereas without --json

Validating Deployment of v61.0 metadata to XXX using the v61.0 SOAP API.
Deploy ID: 0AfdL000004QTDlSAO
Status: Failed | ████████████████████████████████████████ | 2/2 Components | 0/1 Tests(Errors:1)
Test Failures [1]
• testtest12.TestNewFileInserted
  message: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, tes23425632.test12: execution of BeforeInsert

Steps To Reproduce

with the following test class

@isTest
private class testtest12 {
    @isTest
    static void TestNewFileInserted() {
        Test.startTest();
        Account accA = new Account(Name = 'File Test');
        insert accA;

        Case caseA = new Case(
            AccountId = accA.Id,
            Status = 'New',
            Subject = 'File Test',
            Description = 'File Test',
            Origin = 'Email'
        );
        insert caseA;
        insert caseA;

        
        ContentVersion content = new ContentVersion();
        content.Title = 'Header_Picture1';
        content.PathOnClient = '/' + content.Title + '.jpg';
        Blob bodyBlob = Blob.valueOf('Unit Test ContentVersion Body');
        content.VersionData = bodyBlob;
        insert content;
        ContentDocumentLink contentlink = new ContentDocumentLink();
        contentlink.LinkedEntityId = caseA.id;
        contentlink.contentdocumentid = [
            SELECT contentdocumentid
            FROM contentversion
            WHERE id = :content.id
        ]
        .contentdocumentid;

        insert contentlink;
        Test.stopTest();
    }
}

Expected result

json would include information about test failure/DML exception like stdout has

Actual result

stack trace only

System Information

bash/macos

{
  "architecture": "darwin-arm64",
  "cliVersion": "@salesforce/cli/2.50.5",
  "nodeVersion": "node-v21.1.0",
  "osVersion": "Darwin 23.5.0",
  "rootPath": "/Users/william.ruemmele/.nvm/versions/node/v20.12.2/lib/node_modules/@salesforce/cli",
  "shell": "zsh",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.1.6 (core)",
    "@oclif/plugin-commands 4.0.6 (core)",
    "@oclif/plugin-help 6.2.5 (core)",
    "@oclif/plugin-not-found 3.2.10 (core)",
    "@oclif/plugin-plugins 5.3.4 (core)",
    "@oclif/plugin-search 1.2.2 (core)",
    "@oclif/plugin-update 4.4.7 (core)",
    "@oclif/plugin-version 2.2.6 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.8 (core)",
    "@oclif/plugin-which 3.2.6 (core)",
    "@salesforce/cli 2.50.5 (core)",
    "apex 3.2.4 (core)",
    "auth 3.6.33 (core)",
    "data 3.5.5 (core)",
    "deploy-retrieve 3.9.13 (core)",
    "info 3.3.17 (core)",
    "limits 3.3.17 (core)",
    "marketplace 1.2.17 (core)",
    "org 4.3.4 (core)",
    "packaging 2.7.0 (core)",
    "schema 3.3.19 (core)",
    "settings 2.3.8 (core)",
    "sobject 1.4.19 (core)",
    "source 3.5.3 (core)",
    "telemetry 3.6.1 (core)",
    "templates 56.3.2 (core)",
    "trust 3.7.13 (core)",
    "user 3.5.17 (core)"
  ]
}

Additional information

@WillieRuemmele WillieRuemmele added bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated labels Jul 9, 2024
Copy link

git2gus bot commented Jul 9, 2024

This issue has been linked to a new work item: W-16198239

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue or pull request that identifies or fixes a bug validated Version information for this issue has been validated
Projects
None yet
Development

No branches or pull requests

2 participants