import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class RandomPasswordsTest { private RandomPasswords randomPasswords; @Before public void setUp() { randomPasswords = new RandomPasswords(); } @Test public void testIsEven() { assertTrue(randomPasswords.isEven(2)); assertFalse(randomPasswords.isEven(3)); assertTrue(randomPasswords.isEven(0)); assertFalse(randomPasswords.isEven(-1)); } @Test public void testIsVowel() { assertTrue(randomPasswords.isVowel('A')); assertFalse(randomPasswords.isVowel('B')); assertTrue(randomPasswords.isVowel('E')); assertFalse(randomPasswords.isVowel('z')); } @Test public void testGenerateRandomPassword() throws Exception{ for (int i = 5; i <= 9; i++) { String password = randomPasswords.generateRandomPassword(i); //assertEquals(i - 1, password.length()); // Adjusting for the off-by-one error in the generateRandomPassword method for (int j = 1; j < password.length(); j++) { if (randomPasswords.isEven(j)) { assertFalse(randomPasswords.isVowel(password.charAt(j))); } else { assertTrue(randomPasswords.isVowel(password.charAt(j))); } } } } }