如何確保在JUnit測試用例中,所有測試中的方法直接/間接產生的線程都是在那裏完成的,這樣我可以斷言最終結果?等待我在JUnit測試用例中測試的代碼產生的所有線程
@Test
public void testMethod() {
Result result=method();// may spawn multiple threads to set result.value
Assert.assertTrue(result.getValue()==4); //should execute only after result.value is set to its final value.
}
+1您的解釋比我的方式更好:-) – 2010-08-18 15:22:19