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

fix: testresult mapping of source deployment #610

Merged
merged 1 commit into from
May 9, 2023

Conversation

R0Wi
Copy link
Contributor

@R0Wi R0Wi commented May 9, 2023

What does this PR do?

@W-13048665@

The mapTestResults method is used by DeployResultFormatter to map the nested test-results of a deployment-result into ApexTestResultData objects, which are later used to generate a JUnit test report. Commit cdc8f6e introduces a bug which is mapping test results without a message property to a failed test and vice versa.

This PR switches the logic back to the original one.

What issues does this PR fix or reference?

forcedotcom/cli#2076

Context info

This is a JSON example for a succeeded test retrieved via deploy API:

{
          "namespace" : null,
          "name" : "MyTest",
          "methodName" : "myTestMethod",
          "id" : "<SOME ID>",
          "time" : 384.0,
          "seeAllData" : null
}

while this is a failed one:

{
          "type" : "Class",
          "namespace" : null,
          "name" : "MyFailingTest",
          "methodName" : "myTestMethodFailing",
          "message" : "System.DmlException: Update failed. First exception on row 1 with id <ID>; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []",
          "stackTrace" : "Class.SomeClass.SomeMethod: line 184, column 1[...]",
          "id" : "<SOME ID>",
          "seeAllData" : null,
          "time" : 3063.0,
          "packageName" : "SomePackage"
        }

@WillieRuemmele
Copy link
Contributor

WillieRuemmele commented May 9, 2023

QA Notes


before: run a command with project deploy start, sfdx project deploy start --verbose --junit --results-dir beforeChanges --test-level RunLocalTests --coverage-formatters json --source-dir force-app --ignore-conflicts to get junit testing

build and run the command from the plugin:
../../oss/pdrROI/bin/dev project:deploy:start --verbose --junit --results-dir sfJunit-ROI --test-level RunLocalTests --coverage-formatters json --source-dir force-app --ignore-conflicts

and confirm the outputs

in the before beforeChanges/junit/junit.xml

       <testcase name="blankAddress" classname="GeocodingServiceTest" time="0.08">
            <failure message=""></failure>
        </testcase>

even the IDE marks the failure tag as empty and suggests removing it

✅ : in the after sfJunit-ROI/junit/junit.xml

        <testcase name="blankAddress" classname="GeocodingServiceTest" time="0.07">
        </testcase>

✅ : --json output matches
✅ : on a failing test it used to print

        <testcase name="successResponse" classname="GeocodingServiceTest" time="0.07">
        </testcase>

and now it prints

        <testcase name="successResponse" classname="GeocodingServiceTest" time="0.06">
            <failure message="System.AssertException: Assertion Failed: Expected: 2, Actual: 1"><![CDATA[(System Code)
Class.GeocodingServiceTest.successResponse: line 32, column 1]]></failure>
        </testcase>

✅ : which matches force source deploy

@WillieRuemmele WillieRuemmele merged commit 6f26779 into salesforcecli:main May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants