I have a method set up to add users to an ArrayList, and return false if the same user is added:
public boolean addUser(K pass, V user)
{
if (username.contains(user))
{
return false;
}
else
{
password.add(pass);
username.add(user);
size++;
return true;
}
}
Then I have a JUnit test to assertFalse(true) because that's what my method returns when adding two users with the same name:
@Test
public void testAddingTwoOfTheSameUserToArrayList() {
User<String, String> user1 = new User<String, String>();
user1.addUser("password", "SpeedinDave");
user1.addUser("password", "SpeedinDave");
assertFalse(true);
}
However, it the test always turns up false (red bar). Any ideas?
assertFalse(true)to do? And why are you never using the results ofaddUser?assertFalse()assertFalseyou should put infalseNOTtrue.