I am doing the unit testing in eclipase 2021-06 (4.20.0) on method convertScore() in Area_Eca class. When I input the test case "Other String,true,,Test invalid input and then throw exception", the system return type error. I expect the system allow me to re enter the value if the input was wrong. I think we should consider user input validation.
For now, the system only accepts the number string and special strings like float number and DSE characters. Therefore when having other strings like "Other String", the system will throw a Java Exception. Adding a function to allow re-entering input and telling users the input have an error. I will pass it to the developer to design a new function to do validation.
I just added a class for validation of the input. The class named Validation. To validate the score, used the following method. ========= public static boolean validationScore(String input, String academicType) { Double temp = 0.0; if(input==null||academicType==null) return false; if(academicType.equals("DSE")) { if(input.equals("5**")||input.equals("5*")||input.equals("5")||input.equals("4")||input.equals("3")||input.equals("2")||input.equals("1")||input.equals("U")) return true; }else { if(!checkDouble(input)) return false; temp = Double.parseDouble(input); if(temp<=4.3 && temp>=0) return true; } return false; } ========= Also added for validation for other input. Now the bug is solved.