Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
fix(diff): ingore coverage validation when diff doesnt contain impact…
Browse files Browse the repository at this point in the history
…ed 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
  • Loading branch information
azlam-abdulsalam committed Sep 14, 2023
1 parent 7846c2d commit 858e195
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 858e195

Please sign in to comment.