bbaldino
05/22/2020, 4:05 PMshouldBe
failure exception in the task just gets swallowed by the executor service. (I know this--using a real executor service/threads--is not a great unit test practice, but it's what I'm stuck with for verifying something for now.)bbaldino
05/22/2020, 4:16 PMCallable
and returned the result and verified outside the task. Would be great to be able to fail the test within the task somehow, though. I think this would involve a method on TestContext
to force-fail it (as an alternative to a thrown exception), but this may not be a common use-case.sam
05/22/2020, 4:45 PMExecutors.newFixedThreadPool(8).submit { error("foom") }
the execution is lostbbaldino
05/22/2020, 4:45 PMsam
05/22/2020, 4:45 PMbbaldino
05/22/2020, 4:46 PMbbaldino
05/22/2020, 4:46 PMsam
05/22/2020, 4:46 PMbbaldino
05/22/2020, 4:47 PMsam
05/22/2020, 4:47 PMExecutors.newFixedThreadPool(5, new ThreadFactory {
override def newThread(r: Runnable): Thread = {
val thread = new Thread(r)
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler {
override def uncaughtException(t: Thread, e: Throwable): Unit = ???
})
thread
}
})
sam
05/22/2020, 4:48 PMsam
05/22/2020, 4:49 PMTestExecutors.fixed(8)
or whatever.bbaldino
05/22/2020, 4:49 PMTestContext
should have a fail method on it or something which matched the behavior of an exception being thrown, but actually I guess we've still got mixed threads there.sam
05/22/2020, 4:50 PMsam
05/22/2020, 4:50 PMbbaldino
05/22/2020, 4:50 PMsam
05/22/2020, 4:50 PMbbaldino
05/22/2020, 4:51 PMsam
05/22/2020, 4:51 PMbbaldino
05/22/2020, 4:52 PMbbaldino
05/22/2020, 4:52 PMsam
05/22/2020, 4:52 PMbbaldino
05/22/2020, 4:52 PMsam
05/22/2020, 4:53 PMsam
05/22/2020, 4:53 PMbbaldino
05/22/2020, 4:53 PMsam
05/22/2020, 4:54 PMbbaldino
05/22/2020, 4:54 PMsam
05/22/2020, 4:54 PMbbaldino
05/22/2020, 4:54 PM