nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

should values "out of scope" be tested? #528

Open nicktohzyu opened 3 years ago

nicktohzyu commented 3 years ago

image From this paper, the method has parameter int n, and the javadocs says that it is only defined for range 10-100. The method does not seem to throw any checked exceptions either. Hence, when designing tests for this method, should values outside of the range be considered?

sudogene commented 3 years ago

We are completely blind to the implementation so we can't really assume it doesn't check for the range. I would think that the mentioned range just helps us narrow down the equivalence partitions (MIN..9, 10..100, 101..MAX). So regardless, we should still test these values.

My thinking is that since they explicitly talk about 10..100, all the more I would want to test the out-of-bound values just to see if it works as specified.

Also, it's kinda strange that the e.g. uses n = 5 which is already outside the specified range

damithc commented 3 years ago

We are completely blind to the implementation so we can't really assume it doesn't check for the range. I would think that the mentioned range just helps us narrow down the equivalence partitions (MIN..9, 10..100, 101..MAX). So regardless, we should still test these values.

My thinking is that since they explicitly talk about 10..100, all the more I would want to test the out-of-bound values just to see if it works as specified.

Yes, values outside of this range are to be considered invalid inputs and should be tested in negative test cases. Indeed, the question doesn't specify the expected behavior for those invalid inputs. Probably left out to reduce the amount of reading required during the exam.

Also, it's kinda strange that the e.g. uses n = 5 which is already outside the specified range

Yes, IIRC, that was a mistake in the question. The valid range was changed for some reason but forgot to change the example.