The bug found when testing calculating the percentage of the product with maximum sales. The expected result of this test case should be 50.0 but the actual result is 0.0.
Step of the test: 1. Find the maximum sales of the product in the database. 2. Calculate the percentage by maximum sales divided by the total number of sales. 3. Round up the result. 4. Calculate the expected percentage. 5. Compare the actual percentage(from step 2 and 3) with the expected percentage(from step 4).
The bug fixed successfully. The bug was fixed by adding a statement to convert the type of max and totalSales from int to double. Otherwise, in the test case, the result of max divided by totalSales will be incorrect as the type is int. To get the correct calculation, the type needs to convert to double first.