From: Daniel Berger Date: 2007-12-08T07:21:17+09:00 Subject: Re: Problem testing certain Thread methods with Test::Unit On Dec 7, 12:34 pm, MenTaLguY wrote: > On Sat, 8 Dec 2007 02:33:59 +0900, Daniel Berger wrote: > > # Assume @thread created in setup > > assert_raise(FooError){ @thread.raise(FooError) } > > > The above test won't work - no error is raised. Any suggestions on how > > I should approach this? > > This should be reasonably robust: > > t = Thread.new { sleep } > Thread.pass until t.status == "sleep" > t.raise FooError > assert_raise(FooError) { t.join } That works nicely, thank you. > > Also, if anyone has any idea how to test that threads abort properly > > with Thread.abort_on_exception = true, I'm all ears. > > I don't think that's possible without starting a child Ruby process. If that's what it takes, that's what I'll do. Suggestions? Thanks, Dan