2009-09-08 12 views

Répondre

4

Vous pouvez essayer ceci:

@Test 
public void methodDoesNotReturnFor5Seconds() throws Exception { 
    Thread t = new Thread(new Runnable() { 
    public void run() { 
     methodUnderTest(); 
    } 
    }); 
    t.start(); 
    t.join(5000); 
    assertTrue(t.isAlive()); 
    // possibly do something to shut down methodUnderTest 
}