From a3433ca1c667985786a5f0bca90458002bfc3c43 Mon Sep 17 00:00:00 2001 From: Ivan Volkov Date: Wed, 31 Aug 2022 19:30:51 +0300 Subject: [PATCH] Support for nested classes in cli #830 --- .../main/kotlin/org/utbot/cli/GenerateTestsCommand.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsCommand.kt b/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsCommand.kt index 2d926d674b..95a8ad3c95 100644 --- a/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsCommand.kt +++ b/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsCommand.kt @@ -21,6 +21,7 @@ import java.nio.file.Paths import java.time.temporal.ChronoUnit import kotlin.reflect.KClass import mu.KotlinLogging +import org.utbot.common.allNestedClasses import org.utbot.common.filterWhen import org.utbot.framework.UtSettings import org.utbot.framework.util.isKnownSyntheticMethod @@ -94,9 +95,11 @@ class GenerateTestsCommand : logger.debug { "Classpath to be used: ${newline()} $classPath ${newline()}" } val classUnderTest: KClass<*> = loadClassBySpecifiedFqn(targetClassFqn) - val targetMethods = classUnderTest.targetMethods() - .filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) { !isKnownSyntheticMethod(it) } - .filterNot { it.callable.isAbstract } + val targetMethods = classUnderTest.allNestedClasses.flatMap { clazz -> + clazz.targetMethods() + .filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) { !isKnownSyntheticMethod(it) } + .filterNot { it.callable.isAbstract } + } val testCaseGenerator = initializeGenerator(workingDirectory) if (targetMethods.isEmpty()) {