equivalence partitioning, boundary value analysis, and branch coverage for the
public class OrderCalculatorTest {
Test (expectedIllegalArgumentException.class)
public void testNoltemsInOrder() {
OrderCalculator calculator = new OrderCalculator();calculator.calculateTotal Price (new double()(), "VIP", false, null); // No itens in order
Test
public void testVIFCustomerWithNoDiscount Code () { OrderCalculator calculator new OrderCalculator();
double total calculator.calculateTotalPrice (new double[] [100, 200), "VIP", true, null); // Branch 1: VIP customer assertEquals (240.0, total, 0.01); // 20% discount
// Add more test
37
白
After completing the tests, students should provide a one-line summary for each test case and copy the test code into a Word document for evaluation.
Example:
ID: TC1; Test for ; Input parameter:; Expected result:
Test code:
@Test
public void testNegativeX() { assertThrows (IllegalArgumentException.class, () -> { numberProcessor.process Numbers(-1, 5, true);
});
}
+ 100%
Zoom
Close