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
A small improvement to Eyal Schneider's answer:
The ExecutorService allows to submit a Callable and any thrown Exceptions or Errors are rethrown by the returned Future.
Consequently, the test can be written as:
@Test
public void test() throws Exception {
ExecutorService es = Executors.newSingleThreadExecutor();
Future> future = es.submit(() -> {
testSomethingThatMightThrowAssertionErrors();
return null;
});
future.get(); // This will rethrow Exceptions and Errors as ExecutionException
}