【发布时间】:2018-11-15 09:28:31
【问题描述】:
以下测试通过Process finished with exit code 0 成功。请注意,此测试确实将异常打印到日志中,但不会使测试失败(这是我想要的行为)。
@Test
fun why_does_this_test_pass() {
val job = launch(Unconfined) {
throw IllegalStateException("why does this exception not fail the test?")
}
// because of `Unconfined` dispatcher, exception is thrown before test function completes
}
正如预期的那样,此测试以Process finished with exit code 255 失败
@Test
fun as_expected_this_test_fails() {
throw IllegalStateException("this exception fails the test")
}
为什么这些测试的行为方式不同?
【问题讨论】: