160,629 views
23 votes
23 votes
consider a method that is provided a numerical grade (0 - 100) as a parameter and returns a corresponding letter grade (a - f). which collection of values would be the most appropriate for testing the method?

User Diazdeteran
by
2.9k points

1 Answer

11 votes
11 votes
Answer: You would want to test from values [-1:101] inclusive and non numeric characters.

Step-by-step explanation:
You want to test the expected input of [0:100] to ensure that you have the expect results of a letter A through F.

You will also want to test outside of that numeric range (i.e., -1 and 101) to see the behavior of your method and insure proper error handling.

Additionally, you will want to test non numeric characters to ensure that the input is not accepted and proper error handling occurs.

If these test cases are passed and the errors handled as expected, your method can be considered viable.

Cheers.
User C Hogg
by
3.0k points