Test Informed Learning with Examples

Logo

Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.

Menu

Membership card discounts

A book store gives discounts to its customers depending on whether the customer has the membership card and the price of the purchase made.

Write a program that asks the user by keyboard how much the purchase is, and whether the customer is a member or not. Depending on these input data, the program has to show on the screen how much the customer has to pay for the purchase.

Run the following test cases to ensure that the program works correctly:

ID abstract test case expected result
1 member with purchase under 10 euros discount 0%
2 non-member with purchase below 10 euros discount 0%
3 member with purchase between 10 and 20 euros discount 5%
4 non-member with purchase between 10 and 20 euros discount 0%
5 member with purchase over 20 euros discount 12%
6 non-member with purchase over 20 euros discount 6%

We call these test cases abstract because, in order to execute them, we first have to think of concrete values that meet the conditions of the test case.

Insist that the students test their programs by giving them example
test cases in a table. Also we introduce the concept of abstract vs
concrete test cases.