This code needs to be tested but I'm not able to resolve the error. Boolean isValid is the method which needs to be tested.
public boolean isValid(String email)
{
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\."+
"[a-zA-Z0-9_+&*-]+)*@" +
"(?:[a-zA-Z0-9-]+\\.)+[a-z" +
"A-Z]{2,7}$";
Pattern pat = Pattern.compile(emailRegex);
if (email == null)
return false;
return pat.matcher(email).matches();
}
Getting error in writing test case: Cannot invoke isEqualTo(boolean) on the primitive type boolean
@Test
public void isValidTest() {
Validation v = new Validation();
String email = "bhavya@gmail.com";
assertEquals(v.isValid(email).isEqualTo(true)); //this line gives the error.
}