Test Issues
Another once-over, and more problems found:
- testExceptionsViolatedInRandomConstructor and testExceptionsViolatedInEvilConstructor do not match the spec.
assertThrows(IllegalStateException.class, () -> Reflection.newInstance(c, -1, 3));
should throw an IllegalArgumentxception by the spec, since wordLength < 1. A more appropriate additional test would be
assertThrows(IllegalStateException.class, () -> Reflection.newInstance(c, Integer.MAX_VALUE, 3));
-
The spec currently expects IllegalStateExceptions due to an empty wordlist to be thrown in the makeGuess method. The tests expect them to be thrown in the constructor. Either the spec or the tests should be corrected for consistency.
-
testMakeGuessExceptionsInRandom is not mentioned in the spec, instead stated as an assumption. I suggest changing the part about assuming valid inputs to something about making sure to validate their inputs and throw an appropriate exception if the input is not valid.
-
testMakeGuessExceptionsInRandom does not test what it is supposed to test. I don't know what Reflection.getMethod() tries to pass in for the constructor, but it isn't a valid argument for the attributes, so it triggers the IllegalAttributeException of the constructor. Not sure what best practice is in this case - @blank?
-
The trace tests appear to be correct at this point, no further changes needed here.