What am I doing wrong that an exception is thrown instead of showing a failure, or should I not have assertions inside threads?
@Test
public void testCompl
I ended up using this pattern it work with both Runnables and Threads. It is largely inspired from the answer of @Eyal Schneider:
private final class ThreadUnderTestWrapper extends ThreadUnderTest {
private Exception ex;
@Override
public void run() {
try {
super.run();
} catch ( Exception ex ) {
this.ex = ex;
}
}
public Exception getException() throws InterruptedException {
super.join(); // use runner.join here if you use a runnable.
return ex;
}
}