Re: Timed Tests and Thread Safety

Cédric Beust ♔ <[email protected]> Fri, 24 May 2013 08:49:56 -0700
Newsgroups gmane.comp.java.junit.user
Message-ID <CAOphgJCoqo8SY=pLnFJAG1oRdz3ZvbWWkkfwHH0T=3-qZ-E8Ag@mail.gmail.com>
On Fri, May 24, 2013 at 8:24 AM, David Saff <[email protected]> wrote:

> You raise a great question.  Unfortunately, and perhaps I'm missing
> something obvious, I don't think there's a way to provide timeout
> semantics, guarantee that @After is called, and guarantee that @After is
> called on the same thread as the @Test method.
>

Why not? When you find a @Test(timeout=...), create a thread, run the
@Before method in it, then the test method, then the @After method, all in
that thread. You can detect if the test times out and still be able to run
the @After in that same thread after the InterruptedException kicks in.

-- 
Cédric


[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/junit/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/junit/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/