From cde849667b4871ea841f37444c7f9b2ac7576464 Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Wed, 15 Jun 2022 15:17:10 +0300 Subject: [PATCH] RunTimeException Error in process of test generation #182 --- .../org/utbot/framework/plugin/api/UtBotTestCaseGenerator.kt | 5 ++++- .../utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGenerator.kt index 5ef2470615..dc1b7153d6 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGenerator.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGenerator.kt @@ -48,6 +48,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.yield import mu.KotlinLogging +import org.utbot.engine.* import soot.Scene import soot.jimple.JimpleBody import soot.toolkits.graph.ExceptionalUnitGraph @@ -403,7 +404,9 @@ object UtBotTestCaseGenerator : TestCaseGenerator { val signature = method.callable.signature val sootMethod = clazz.methods.singleOrNull { it.pureJavaSignature == signature } ?: error("No such $signature found") - + if (!sootMethod.canRetrieveBody()) { + error("No method body for $sootMethod found") + } val methodBody = sootMethod.jimpleBody() val graph = methodBody.graph() diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt index 7df71aa2f5..6b079e094f 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/actions/GenerateTestsAction.kt @@ -58,6 +58,7 @@ class GenerateTestsAction : AnAction() { e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)?.let { srcClasses += getAllClasses(project, it) } + srcClasses.removeIf { it.isInterface } var commonSourceRoot = null as VirtualFile? for (srcClass in srcClasses) { if (commonSourceRoot == null) {