Following is the code from the information system of Video Buster video rental c
ID: 3911902 • Letter: F
Question
Following is the code from the information system of Video Buster video rental company. The purpose of the following program is to calculate the fee of the rental.
Float calcRentalFee(Tape[] tapes, Customer customer){
float total = 0; for(int I = 0; I < tapes.length; I++){
total += tapes[I].price;
}
if (tapes.length > 10){ total *= .8;
}
else if(tapes.length > 5){ total *= .9;
}
if(customer.isPremium()){ total *= .9;
}
return total;
}
A. Using EP/BVA techniques, how many test cases are needed?
B. How many test cases are needed to achieve 100% branch coverage?
Explanation / Answer
Test cases for the above problem -
1. tapes name having blank name
2. tapes name having one character
3. tapes name having 5-10 characters
4. tapes name containing 20 characters
5. customer name having the blank name
6. customer name having one character
7. customer name having 5-10 characters
8. customer name containing 20 characters
9. Check when tapes.length = 0
10. Check when tapes.length = 7
11. Check when tapes.length > 10
11. Check when tapes.price = 0
12. Check when tapes.price is a negative integer
13. Check when tapes.price is a positive integer
To achieve 100% branch coverage we need the 4 test cases -
1. need to check behavior when tapes.length > 10
2. need to check behavior when tapes.length < 10 and > 5
3. need to check behavior when tapes.length < 5
4. need to check Customer premium membership.