Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.coroutines.yield
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
import org.utbot.framework.minimization.minimizeExecutions
import org.utbot.framework.plugin.api.util.isSynthetic

internal const val junitVersion = 4
Expand Down Expand Up @@ -180,10 +181,7 @@ fun runGeneration(
runFromEstimator: Boolean,
methodNameFilter: String? = null // For debug purposes you can specify method name
): StatsForClass = runBlocking {



val testSets: MutableList<UtMethodTestSet> = mutableListOf()
val testsByMethod: MutableMap<ExecutableId, MutableList<UtExecution>> = mutableMapOf()
val currentContext = utContext

val timeBudgetMs = timeLimitSec * 1000
Expand Down Expand Up @@ -340,8 +338,7 @@ fun runGeneration(
}
statsForClass.testedClassNames.add(className)

//TODO: it is a strange hack to create fake test case for one [UtResult]
testSets.add(UtMethodTestSet(method, listOf(result)))
testsByMethod.getOrPut(method) { mutableListOf() } += result
} catch (e: Throwable) {
//Here we need isolation
logger.error(e) { "Code generation failed" }
Expand Down Expand Up @@ -393,6 +390,8 @@ fun runGeneration(
}
cancellator.cancel()

val testSets = testsByMethod.map { (method, executions) -> UtMethodTestSet(method, minimizeExecutions(executions)) }

logger.info().bracket("Flushing tests for [${cut.simpleName}] on disk") {
writeTestClass(cut, codeGenerator.generateAsString(testSets))
}
Expand Down