Excuse what may be a fairly trivial question:
I’m unit testing a ‘setPercentage(int percent){…}’ method. The requirements don’t state anything about there being an ‘acceptable range’ or allowable values… but I know from the application in question that the percentage should only ever be between 0 and 100.
Should I be testing if the value being set makes sense (in the context of unit testing?)
i.e. should I write unit tests that fail if percentage is set > 100 or < 0?
If the documentation of the method does not explicitly say that such values are not allowed, you should definitely write unit tests for values outside the proper range. There will be users, who will provide incorrect values — and rightly so, the documentation did not tell not to.