後果 的告誡

後果 的告誡

後果 的告誡

後果 的告誡

// Don’t run unless you
// have some time to kill.
public void _testWithReallyBigFile()
{

}

現在可以用@Ignore屬性來關閉測試案例,並附上適當
的說明文字。如@Ignore(“Takes too long to run”)
但在JUnit4之前的年代,在函式名稱前加上一個底線是
常見的慣例,而這個註解雖然輕率但也相當不錯。

public static SimpleDateFormat makeStandardHttpDateFormat()
{
//SimpleDateFormat is not thread safe.
//so we need to create each instance independently.
SimpleDateFormat df = new SimpleDateFormat…

return df;
}

大家可能覺得有更好的辦法來解決上述問題,但這註解被放置於此,
可說是相當有道理。可避免操之過急的程式設計師為了追求更好的
效率而直接使用靜態初始器。