30.
Question 2 (3 points): Assuming you are assigned to conduct the component test for the method
below, please design and create the minimum component test cases (Unit Test case) needed to
achieve 100% statement covergage and 100% decision coverage. (Use question 2 template)
Note: Assume all parameters are provided and have the correct data types.
1. double calculateInsurance Fee (int vehicleType, int age, int years Experience, boolean isVIP) {
double baseFee;
Zoom
2.
3.
4.
switch (vehicleType) {
5.
case 1: baseFee
6.
case 2: baseFee
7.
8.
9.
1000000; break; // Motorcycle
5000000; break; // Car (under 7 seats)
case 3: baseFee = 7000000; break; // Truck
case 4: baseFee = 10000000; break; // Bus
default: return -1; // Invalid vehicle type
10.
}
11.
12.
int ageGroup;
13.
if (age <25) {
14.
ageGroup 1; // Under 25
15.
16.
17.
18.
}else if (age <= 60) {
ageGroup 2; // 25-60
} else {
ageGroup 3; // Over 60
19.
}
20.
21.
22.
23.
24.
ཀླུཐཱ
double factor;
switch (ageGroup) {
case 1: factor = 1.2; break;
case 2: factor = 1.0; break;
+ 100%
Close