I'm trying to write a JUnit test for this piece of code:
@Override
public boolean equals(Object obj)
{
if (obj == null) //base case
{
return false;
}
if (obj == this) //base case
{
return true;
}
if (obj.getClass() == this.getClass()) //base case
{
Employee person = (Employee)obj; //casting from obj to employee
if (name.equals(person.getName()))
{
return true;
}
}
return false;
So far I have this which takes care of the first two lines but am stuck on the rest. Any idea?
public void testEquals()
{
assertFalse(girl.equals(null));
assertNotNull(gitl.equals(this));
}
Aucun commentaire:
Enregistrer un commentaire