From a5521059d2717ffda717f2f6f32e2fc54a82df8a Mon Sep 17 00:00:00 2001 From: Jonny Power Date: Thu, 20 Jul 2023 20:31:05 -0700 Subject: [PATCH] fix(namespace): fix namespaces on reported class names Related to: #1362 --- .../core/src/apextest/TriggerApexTests.ts | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/packages/core/src/apextest/TriggerApexTests.ts b/packages/core/src/apextest/TriggerApexTests.ts index df71b5505..17766e825 100644 --- a/packages/core/src/apextest/TriggerApexTests.ts +++ b/packages/core/src/apextest/TriggerApexTests.ts @@ -119,6 +119,8 @@ export default class TriggerApexTests { { retries: 2, minTimeout: 3000 } ); + testResult = this.fixBadNamespaceClassFullNames(testResult); + //Collect Failed Tests only if Parallel testResult = await this.triggerSecondRunInSerialForParallelFailedTests( testResult, @@ -401,11 +403,15 @@ export default class TriggerApexTests { { retries: 2, minTimeout: 3000 } ); + secondRuntestRunResult = this.fixBadNamespaceClassFullNames(secondRuntestRunResult); + //Fetch Test Results - const secondTestResult = await testService.reportAsyncResults( - secondRuntestRunResult.summary.testRunId, - true, - this.cancellationTokenSource.token + const secondTestResult = this.fixBadNamespaceClassFullNames( + await testService.reportAsyncResults( + secondRuntestRunResult.summary.testRunId, + true, + this.cancellationTokenSource.token + ) ); this.writeTestOutput(secondTestResult); @@ -430,6 +436,27 @@ export default class TriggerApexTests { return modifiedTestResult; } + private fixBadNamespaceClassFullNames(testResult: any): any { + let modifiedTestResult = _.cloneDeep(testResult); + + modifiedTestResult.tests = modifiedTestResult.tests.map((test) => { + return { + ...test, + ...{ + fullName: test.fullName.replace('__', '.'), + apexClass: { + ...test.apexClass, + ...{ + fullName: test.apexClass.fullName.replace('__', '.'), + }, + }, + }, + }; + }); + + return modifiedTestResult; + } + private combineTestResult(testResult: TestResult, testResultSecondRun?: TestResult) { testResult.summary.failing = 0; testResult.summary.passing = 0;