Fix a test that checks nothing
A test passes when nothing throws.
Your task
Fix both verifiers so a wrong total, a missing error and a wrong error message each make the test fail.
@IsTest
public class AS_98EF88F18834_PricingTests {
public static void verifyTotal(List<Decimal> prices, Decimal taxRate, Decimal expected) {
Decimal result = AS_98EF88F18834_Pricing.total(prices, taxRate);
System.debug('Total: ' + result);
}
public static void verifyRejected(List<Decimal> prices, Decimal taxRate) {
try {
AS_98EF88F18834_Pricing.total(prices, taxRate);
} catch (IllegalArgumentException error) {
System.debug('Rejected: ' + error.getMessage());
}
}
@IsTest
static void totalsTwoPrices() {
verifyTotal(new List<Decimal>{ 10, 20 }, 10, 33.00);
}
@IsTest
static void rejectsANegativePrice() {
verifyRejected(new List<Decimal>{ -5 }, 10);
}
}Requirements
- verifiesACorrectTotal should pass
- verifiesARoundedTotal should pass
- catchesAWrongTotal should pass
- verifiesARejection should pass
- catchesAMissingRejection should pass
- catchesAWrongMessage should pass