我有以下内容
public class PlayerHandler {
public static class PlayerValue {
public String name;
public String value;
public String status;
@Override
public boolean equals(Object o) {
PlayerValue playerValue = (PlayerValue) o;
return playerValue != null && StringUtils.equals(playerValue.name, name)
&& StringUtils.equals(playerValue.value, value) && StringUtils.equals(playerValue.status, status);
}
}
}
如何为此编写jUnit?请帮忙。
private PlayerHandler.PlayerValue value;
private PlayerHandler.PlayerValue value2;
@BeforeTest(){
value = new PlayerHandler.PlayerValue();
value2 =new PlayerHandler.PlayerValue();
value.name = "name1";
value.playerValue = "value1";
value.status = "status1";
}
@Test
public void checkEquals(){
value2.name = value.name;
value2.playerValue = value.playerValue;
value2.status = value.status;
assertEquals(value , value2 );
}
@Test
public void checkThaNotEquals(){
value2.name = "value2";
value2.playerValue = "playerValue2";
value2.status = "status 2";
assertNotEquals(value , value2 );
}
@Test
public void checkNotEqualsWithNull(){
assertNotEquals(value , null);
}