From 858e1952dce028bf8b46e75086f9975d8e79a119 Mon Sep 17 00:00:00 2001 From: azlam Date: Fri, 15 Sep 2023 01:03:45 +1000 Subject: [PATCH] fix(diff): ingore coverage validation when diff doesnt contain impacted apex classes In certain scenarios, such as refactoring an existing test class, the diff package or the new baseline doesnt contain the class under test, this could result in incorrect coverage validation. This change address this by ignoring coverage validation --- .../src/impl/validate/ApexTestValidator.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/sfpowerscripts-cli/src/impl/validate/ApexTestValidator.ts b/packages/sfpowerscripts-cli/src/impl/validate/ApexTestValidator.ts index d2687d940..555af29c7 100644 --- a/packages/sfpowerscripts-cli/src/impl/validate/ApexTestValidator.ts +++ b/packages/sfpowerscripts-cli/src/impl/validate/ApexTestValidator.ts @@ -122,6 +122,17 @@ export class ApexTestValidator { return { testOptions: undefined, testCoverageOptions: undefined }; } + let isImpactedApexClassAvailable:boolean = true; + //Unable to find impacted apex class in the diff package + if(!this.sfpPackage.apexClassWithOutTestClasses || this.sfpPackage.apexClassWithOutTestClasses.length==0) + { + isImpactedApexClassAvailable = false; + SFPLogger.log( + `${COLOR_HEADER( + "Unable to find any impacted classses in the diff package,skipping tests, Ignoring coverage validation", + )}`); + } + SFPLogger.log( `${COLOR_HEADER( "Diff package detected: triggering impacted test classes", @@ -135,7 +146,7 @@ export class ApexTestValidator { true, ); const testCoverageOptions = { - isIndividualClassCoverageToBeValidated: true, + isIndividualClassCoverageToBeValidated: isImpactedApexClassAvailable?true:false, isPackageCoverageToBeValidated: false, coverageThreshold: this.props.coverageThreshold || 75, classesToBeValidated: this.sfpPackage.apexClassWithOutTestClasses