@@ -61,6 +61,7 @@ import kotlinx.coroutines.runBlocking
6161import kotlinx.coroutines.withTimeoutOrNull
6262import kotlinx.coroutines.yield
6363import org.utbot.framework.codegen.services.language.CgLanguageAssistant
64+ import org.utbot.framework.minimization.minimizeExecutions
6465import org.utbot.framework.plugin.api.util.isSynthetic
6566
6667internal const val junitVersion = 4
@@ -180,10 +181,7 @@ fun runGeneration(
180181 runFromEstimator : Boolean ,
181182 methodNameFilter : String? = null // For debug purposes you can specify method name
182183): StatsForClass = runBlocking {
183-
184-
185-
186- val testSets: MutableList <UtMethodTestSet > = mutableListOf ()
184+ val testsByMethod: MutableMap <ExecutableId , MutableList <UtExecution >> = mutableMapOf ()
187185 val currentContext = utContext
188186
189187 val timeBudgetMs = timeLimitSec * 1000
@@ -340,8 +338,7 @@ fun runGeneration(
340338 }
341339 statsForClass.testedClassNames.add(className)
342340
343- // TODO: it is a strange hack to create fake test case for one [UtResult]
344- testSets.add(UtMethodTestSet (method, listOf (result)))
341+ testsByMethod.getOrPut(method) { mutableListOf () } + = result
345342 } catch (e: Throwable ) {
346343 // Here we need isolation
347344 logger.error(e) { " Code generation failed" }
@@ -393,6 +390,8 @@ fun runGeneration(
393390 }
394391 cancellator.cancel()
395392
393+ val testSets = testsByMethod.map { (method, executions) -> UtMethodTestSet (method, minimizeExecutions(executions)) }
394+
396395 logger.info().bracket(" Flushing tests for [${cut.simpleName} ] on disk" ) {
397396 writeTestClass(cut, codeGenerator.generateAsString(testSets))
398397 }
0 commit comments