đáp-án-fall2024-1
đáp-án-fall2024-1
Q2:
ID TC1
Test for VIP customer with no discount code
Input itemPrices = {100, 200}
parameter customerType = “VIP”
isVip = true
discountCode = null
Expected 240
result
Test code @Test
public void testVIPCustomerWithNoDiscountCode() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "VIP", true,
null);
assertEquals(240, total, 0.01);
}
ID TC2
Test for VIP customer with discount code “SALE10”
Input itemPrices = {100, 200}
parameter customerType = “VIP”
isVip = true
discountCode = “SALE10”
Expected 210
result
Test code @Test
public void testVIPCustomerWithDiscountCodeSale10() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "VIP", true,
"SALE10");
assertEquals(210, total, 0.01);
}
ID TC3
Test for VIP customer with discount code “WELCOME5”
Input itemPrices = {100, 200}
parameter customerType = “VIP”
isVip = true
discountCode = “WELCOME5”
Expected 225
result
Test code @Test
public void testVIPCustomerWithDiscountCodeWelcome5() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "VIP", true,
"WELCOME5");
assertEquals(225, total, 0.01);
}
ID TC4
Test for Regular customer with no discount code
Input itemPrices = {100, 200}
parameter customerType = “Regular”
isVip = false
discountCode = null
Expected 285
result
Test code @Test
public void testRegularCustomerWithNoDiscountCode() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "Regular",
false, null);
assertEquals(285, total, 0.01);
}
ID TC5
Test for Regular customer with discount code “SALE10”
Input itemPrices = {100, 200}
parameter customerType = “Regular”
isVip = false
discountCode = “SALE10”
Expected 255
result
Test code @Test
public void testRegularCustomerWithDiscountCodeSale10() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "Regular",
false, "SALE10");
assertEquals(255, total, 0.01);
}
ID TC6
Test for Regular customer with discount code “WELCOME5”
Input itemPrices = {100, 200}
parameter customerType = “Regular”
isVip = false
discountCode = “WELCOME5”
Expected 270
result
Test code @Test
public void testRegularCustomerWithDiscountCodeWelcome5() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "Regular",
false, "WELCOME5");
assertEquals(270, total, 0.01);
}
ID TC7
Test for Normal customer (non-VIP and non-regular) with no discount code
Input itemPrices = {100, 200}
parameter customerType = “Normal”
isVip = false
discountCode = null
Expected 300
result
Test code @Test
public void testNormalCustomerWithNoDiscountCode() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "Normal",
false, null);
assertEquals(300, total, 0.01);
}
ID TC8
Test for Normal customer (non-VIP and non-regular) with discount code “SALE10”
Input itemPrices = {100, 200}
parameter customerType = “Normal”
isVip = false
discountCode = “SALE10”
Expected 270
result
Test code @Test
public void testNormalCustomerWithDiscountCodeSale10() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "Normal",
false, "SALE10");
assertEquals(270, total, 0.01);
}
ID TC9
Test for Normal customer (non-VIP and non-regular) with discount code “WELCOME5”
Input itemPrices = {100, 200}
parameter customerType = “Normal”
isVip = false
discountCode = “WELCOME5”
Expected 285
result
Test code @Test
public void testNormalCustomerWithDiscountCodeWelcome5() {
double total = calculator.calculateTotalPrice(new double[] {100, 200}, "Normal",
false, "WELCOME5");
assertEquals(285, total, 0.01);
}
Q3:
ID: TC001
Description: Test order success with discount code
Precondition:
- The customer id logged in
- The shopping cart contains at least item (Eg: a tea cup for 2$)
Test steps:
- Customer add a tea cup to their shopping cart
- Customer applies discount code “SAVE10”
- System validates the discount code “SAVE10”
- The customer proceeds to checkout
- The system displays the bill: Total Amount = 1.8$, Discount = 10%
- Customer select a credit card payment
- Customer provide card number “1234 5678 9101 1121”
- System processes the payment
- The system confirms the order and generates an order confirmation
Expected results:
- The customer receives an order confirmation and an estimated delivery time.
- The system updates the inventory base on the order
Notes: Normal Flow (NF)
ID: TC002
Description: Test order fail due to empty cart
Precondition:
- The customer id logged in
- The shopping cart does not contain any item
Test steps:
- Customer view an empty cart
- The customer proceeds to checkout
- The system displays: “Cart is empty, please add items to the cart to proceed checkout.”
Expected results:
- The customer receives a notification message about empty cart from the system
Notes: Alternative Flow (A1)
ID: TC003
Description: Test order fail due to invalid discount code
Precondition:
- The customer id logged in
- The shopping cart contains at least item (Eg: a tea cup for 2$)
Test steps:
- Customer add a tea cup to their shopping cart
- Customer applies discount code “SAVE50”
- System validates the discount code “SAVE50”
- The customer proceeds to checkout
- The system displays a warning notification: “Discount code is invalid”
- The system ask customer to refill the discount code
Expected results:
- The customer receives a notification message about invalid discount code from the
system
- The system asks the customer to refill the discount code
Notes: Alternative Flow (A2)
ID: TC004
Description: Test order fail due to invalid card detail
Precondition:
- The customer id logged in
- The shopping cart contains at least item (Eg: a tea cup for 2$)
Test steps:
- Customer add a tea cup to their shopping cart
- The customer proceeds to checkout
- The system displays the bill: Total Amount = 2$, Discount = 0
- Customer select a credit card payment
- Customer provide card number “1234 5678 9101 1121”
- System displays a warning notification: “Card number is invalid”
- System asks customer to refill card detail
Expected results:
- The customer receives a notification message about invalid card detail from the system
- The system asks the customer to refill the card detail
Notes: Alternative Flow (A3)