我測試一類稱爲SetOfUsers和followes我正在測試的方法:JUnit測試失敗
public void testAddUser()
{
System.out.println("addUser");
User aUser = new User("Bob","abc123","Manager");
SetOfUsers instance = new SetOfUsers();
instance.addUser(aUser);
System.out.print(aUser);
assertEquals("Bob,abc123,Manager", instance);
// TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
}
然而,這種測試失敗我正在顯示
testAddUser Failed: expected: <Bob, abc123,Manager> but was: <[Staff Name:Bob]>
您比較一個字符串和一個對象SetOfUsers。我會告訴你實現setOfUsers的「equals()」方法,以便比較它的內容。 – Fabinout