Background: I am doing the unit testing in Eclipse 2021-06 (4.20.0) on method convertScore() in Area_Location class. I am testing some locations like Hung Shui Kiu, with similar characteristics that the converted score calculation result is not an integer Steps to Reproduce: 1. Run the package with testHall_Admission 2. Run the method “void testConvertScore” in testArea_eca class 3. Run @ParameterizedTest with “/testResource/testCreateArea_eca.csv” 4. Input the test case "Hung Shui Kiu" Actual result: After the run the above steps, the system returns “0.0” and show the error “org.opentest4j.AssertionFailedError: Test convert Hung Shui Kiu to score ==> expected: <8.0> but was: <0.0>” in the console. Expected result: I expect the system to return “8.0” and pass the assertEquals.
The input of “Hung Shui Kiu” into the method convertScore() in Area_Location class should have returned “8.0”. Therefore it is a bug. I expect the bug is within method convertScore() in Area_Location class. I will pass it to the developer to solve this bug.
I just checked the method Area_Location and the return has a problem. It should have rounding in the calculation not just “return locationScore[i]/100*10;”. To solve the number rounding problem, the return statement was trained. Solution: =============== public static int convertScore(String rawData) { for (int i = 0; i < locationList.length; i++) { if(rawData.equals(locationList[i])) { return (int) Math.round(locationScore[i]/100.0*10.0); } } }