假設你有一個像JUnit中,測試了 「新」 的參考
public Something copy() {
return new Something();
}
的方法在你的JUnit,你有
Something s1 = new Something();
Something s2 = s1.copy()
其他然後
assertTrue (s1 != s2);
assertTrue (s2 != null);
assertTrue (s1.toString().equals(s2.toString)));
是否有任何額外的你可以確認一個NEW引用是由copy()返回嗎?
很酷;謝謝Jon – JAM