ApexSensei

Drills Unit testing

Test success and exceptions

Test the happy path and the error path.

Your task

Finish both verifiers so a wrong amount, a wrong message or a missing error all fail the test.

@IsTest
public class AS_ECE22D24B8C0_DiscountTests {
    public static Decimal verifySuccess(Decimal amount, Decimal percent, Decimal expected) {
        Decimal actual = AS_ECE22D24B8C0_Discount.apply(amount, percent);
        return null;
    }

    public static String verifyRejected(Decimal amount, Decimal percent, String expectedMessage) {
        return null;
    }

    @IsTest
    static void validDiscount() {
        verifySuccess(100, 15, 85.00);
    }
}

Requirements

  1. verifiesNormalResult should pass
  2. verifiesRoundedResult should pass
  3. verifiesRejectedInputs should pass
  4. catchesWrongAmount should pass
  5. catchesMissingError should pass
  6. catchesWrongMessage should pass

Sign in to open this drill