AhChing11
AhChing11

Reputation: 155

How to i test invalid input in jMock?

I want to test for invalid input for the method calculateChange() in Sale class. How do i verify the expectation?

Is it correct by checking whether the value return from calculatechange() is null to verify that the input is invalid?

Below is my initialization for the test.

 public void testCalculateChange() {
            final char paidAmount = 'a';
            Sale.totalPrice = 28.50;

    }

Below is my Sale Class.

public class Sale {
    public static double totalPrice=0;
    private static double change;


    private Sale() {}

    public static double calculateChange(double paidAmount) {
        change = paidAmount - totalPrice;            
        return change;
    }
}

Upvotes: 0

Views: 119

Answers (0)

Related Questions