这是我需要测试的员工超类的代码。
public abstract class Employee {
protected int id;
protected double weeklyPay;
public Employee(int id)
{
this.id=id;
}
public void setId(int id)
{
this.id=id;
}
public int getId()
{
return id;
}
public String toString()
{
return id+"has a weekly pay of "+weeklyPay;
}
public double getWeeklyPay()
{
return weeklyPay;
}
这是ManagerClass的代码
public class Manager extends Employee
public Manager(int id, double weeklyPay)
{
super(id);
super.weeklyPay=weeklyPay;
}
public String toString()
{
return "Manager " + super.toString();
}
这是经理 JUnit Test 中不起作用的部分
public void testToString() {
assertEquals("Manager 1has a weekly pay of 42", new Manager(1, 42).toString());
这是我收到的失败消息 org.junit.ComparisonFailure: expected <...sa week pay of 42[]> but is <...sa week pay of 42[.0]>