From 90aa1e32909a83deb954a134bbd454208b83bf2a Mon Sep 17 00:00:00 2001 From: Maksim Pelevin Date: Thu, 4 Aug 2022 11:48:10 +0300 Subject: [PATCH] Test generation fails if any unexpected exception occurs for a single method #661 --- .../framework/plugin/api/TestCaseGenerator.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt index a661802d50..087df15112 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.collect import kotlinx.coroutines.isActive import kotlinx.coroutines.launch @@ -159,12 +160,16 @@ open class TestCaseGenerator( engineActions.map { engine.apply(it) } - generate(engine).collect { - when (it) { - is UtExecution -> method2executions.getValue(method) += it - is UtError -> method2errors.getValue(method).merge(it.description, 1, Int::plus) + generate(engine) + .catch { + logger.error(it) { "Error in flow" } + } + .collect { + when (it) { + is UtExecution -> method2executions.getValue(method) += it + is UtError -> method2errors.getValue(method).merge(it.description, 1, Int::plus) + } } - } } controller.paused = true }