My first test (randomUpperCaseLetter
) checks if the returned random letter is an uppercase ASCII one. The second one (compareCharactersWithAsciiCodes
) is just me trying to understand Java.
package com.company.letter;
import com.company.RandomLetter;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class RandomLetterTest {
@Test
public void randomUpperCaseLetter() {
char letter = new RandomLetter().generate();
int upperCaseAAsciiCode = 65;
int upperCaseZAsciiCode = 90;
assertTrue(letter >= upperCaseAAsciiCode && letter <= upperCaseZAsciiCode);
}
@Test
public void compareCharactersWithAsciiCodes() {
assertEquals(65, 'A');
assertEquals(90, 'Z');
assertEquals(76, 'L');
assertEquals(77, 'M');
assertEquals(78, 'N');
}
}
Is the first test valuable enough to keep it? What about the second one? Uncle Bob say something about tests to understand how the language works. I don't remember when/where.
Do you have suggestions to improve its readability?