Skip to main content
1 of 4
MaxZoom
  • 321
  • 3
  • 8

The main thing I've noticed is the usage of int type to represent characters. Characters are store in the memory as number but as for testing I would expect to see char in their human readable form. For example:

public void randomUpperCaseLetter() {
    char letter = new RandomLetter().generate();
    int upperCaseAAsciiCode = 65;
    int upperCaseZAsciiCode = 90;
    assertTrue(letter >= upperCaseAAsciiCode && letter <= upperCaseZAsciiCode);
}

should be written for clarity as

public void randomUpperCaseLetter() {
    char letter = new RandomLetter().generate();
    assertTrue(letter >= 'A' && letter <= 'Z' );
}

To better test the letter generation functionality, I would add more occurrences to above method (possibly put a loop to generate more letters).

For the second test method, it seems to be unnecessary. The letter 'A' will always have ASCII character code 65 and there is no need to test it.

public void compareCharactersWithAsciiCodes() {
    assertEquals(65, 'A');
    :
}
MaxZoom
  • 321
  • 3
  • 8