When testing the function of calculating the average expenditure of each product, the expected result and the actual result do not match. The expected result is 169.67, but the return value of the function of salesSystem.averageExpenditure_perItem() is 169.66666666666666.
Step of the test case: 1. Sum up all the income of the product. 2. Calculate the average expenditure by total income divided by the total number of products. 3. Calculate the expected average expenditure. 4. Compare the actual average expenditure(from step 2) with the expected average expenditure(from step 4).
The bug fixed successfully by adding BigDecimal to round up the calculated result of the actual average Expenditure. By rounding up the result to 2 decimals, the problem can be fixed and the actual result will then equal the expected result (169.67).