diff --git a/HowToUseLoggers.md b/HowToUseLoggers.md index 0988afdf02..fdb3da4bed 100644 --- a/HowToUseLoggers.md +++ b/HowToUseLoggers.md @@ -18,7 +18,7 @@ The file is usually in the resource folder. The easiest way is: -- Go in the code that you are going to debug. Let’s assume it is a method in org.utbot.framework.plugin.api.UtBotTestCaseGenerator. +- Go in the code that you are going to debug. Let’s assume it is a method in org.utbot.framework.plugin.api.TestCaseGenerator. - Find out if there is a KotlinLogging object that is used to create a **logger** - If such a logger exists, use the fully qualified class name as the logger name in the next steps
@@ -28,7 +28,7 @@ The easiest way is: Open log4j2.xml and add the logger in the loggers section like this ``` - + ``` diff --git a/utbot-analytics/src/test/kotlin/org/utbot/features/FeatureProcessorWithRepetitionTest.kt b/utbot-analytics/src/test/kotlin/org/utbot/features/FeatureProcessorWithRepetitionTest.kt index 3c0176fd3e..9fe546a8f3 100644 --- a/utbot-analytics/src/test/kotlin/org/utbot/features/FeatureProcessorWithRepetitionTest.kt +++ b/utbot-analytics/src/test/kotlin/org/utbot/features/FeatureProcessorWithRepetitionTest.kt @@ -5,13 +5,13 @@ import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.utbot.analytics.EngineAnalyticsContext -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.withFeaturePath import java.io.File import java.io.FileInputStream -class FeatureProcessorWithRepetitionTest : AbstractTestCaseGeneratorTest(OnePath::class, false) { +class FeatureProcessorWithRepetitionTest : UtTestCaseChecker(OnePath::class, false) { companion object { const val featureDir = "src/test/resources/features" fun reward(coverage: Double, time: Double) = RewardEstimator.reward(coverage, time) diff --git a/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt b/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt index 3db74fb999..5a77dbbaee 100644 --- a/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt +++ b/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt @@ -8,6 +8,7 @@ import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.unique import com.github.ajalt.clikt.parameters.types.choice import com.github.ajalt.clikt.parameters.types.long +import mu.KotlinLogging import org.utbot.common.PathUtil.classFqnToPath import org.utbot.common.PathUtil.replaceSeparator import org.utbot.common.PathUtil.toPath @@ -19,14 +20,13 @@ import org.utbot.framework.codegen.ForceStaticMocking import org.utbot.framework.codegen.MockitoStaticMocking import org.utbot.framework.codegen.NoStaticMocking import org.utbot.framework.codegen.StaticsMocking -import org.utbot.framework.codegen.model.ModelBasedTestCodeGenerator +import org.utbot.framework.codegen.model.CodeGenerator import org.utbot.framework.codegen.testFrameworkByName import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.framework.plugin.api.MockFramework import org.utbot.framework.plugin.api.MockStrategyApi import org.utbot.framework.plugin.api.TreatOverflowAsError -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtMethod import org.utbot.framework.plugin.api.UtTestCase import org.utbot.summary.summarize @@ -41,7 +41,6 @@ import java.time.temporal.ChronoUnit import kotlin.reflect.KCallable import kotlin.reflect.KClass import kotlin.reflect.jvm.kotlinFunction -import mu.KotlinLogging private const val LONG_GENERATION_TIMEOUT = 1_200_000L @@ -160,7 +159,7 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) : searchDirectory: Path, chosenClassesToMockAlways: Set ): List = - UtBotTestCaseGenerator.generateForSeveralMethods( + TestCaseGenerator.generateTestCases( targetMethods, mockStrategy, chosenClassesToMockAlways, @@ -199,21 +198,20 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) : // Set UtSettings parameters. UtSettings.treatOverflowAsError = treatOverflowAsError == TreatOverflowAsError.AS_ERROR - UtBotTestCaseGenerator.init(workingDirectory, classPathNormalized, System.getProperty("java.class.path")) { false } + TestCaseGenerator.init(workingDirectory, classPathNormalized, System.getProperty("java.class.path")) } - private fun initializeCodeGenerator(testFramework: String, classUnderTest: KClass<*>): ModelBasedTestCodeGenerator { + private fun initializeCodeGenerator(testFramework: String, classUnderTest: KClass<*>): CodeGenerator { val generateWarningsForStaticMocking = forceStaticMocking == ForceStaticMocking.FORCE && staticsMocking is NoStaticMocking - return ModelBasedTestCodeGenerator().apply { + return CodeGenerator().apply { init( testFramework = testFrameworkByName(testFramework), classUnderTest = classUnderTest.java, - mockFramework = MockFramework.MOCKITO, // TODO: rewrite default mock framework system codegenLanguage = codegenLanguage, staticsMocking = staticsMocking, forceStaticMocking = forceStaticMocking, - generateWarningsForStaticMocking = generateWarningsForStaticMocking + generateWarningsForStaticMocking = generateWarningsForStaticMocking, ) } } diff --git a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt index be42ca8e4b..1617e5d2fe 100644 --- a/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt +++ b/utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/Api.kt @@ -33,16 +33,6 @@ import org.utbot.framework.plugin.api.util.primitiveTypeJvmNameOrNull import org.utbot.framework.plugin.api.util.shortClassId import org.utbot.framework.plugin.api.util.toReferenceTypeBytecodeSignature import org.utbot.framework.plugin.api.util.voidClassId -import java.io.File -import java.lang.reflect.Modifier -import java.nio.file.Path -import kotlin.jvm.internal.CallableReference -import kotlin.reflect.KCallable -import kotlin.reflect.KClass -import kotlin.reflect.KFunction -import kotlin.reflect.full.instanceParameter -import kotlin.reflect.jvm.javaConstructor -import kotlin.reflect.jvm.javaType import soot.ArrayType import soot.BooleanType import soot.ByteType @@ -58,6 +48,15 @@ import soot.Type import soot.VoidType import soot.jimple.JimpleBody import soot.jimple.Stmt +import java.io.File +import java.lang.reflect.Modifier +import kotlin.jvm.internal.CallableReference +import kotlin.reflect.KCallable +import kotlin.reflect.KClass +import kotlin.reflect.KFunction +import kotlin.reflect.full.instanceParameter +import kotlin.reflect.jvm.javaConstructor +import kotlin.reflect.jvm.javaType data class UtMethod( val callable: KCallable, @@ -1017,17 +1016,6 @@ open class TypeParameters(val parameters: List = emptyList()) class WildcardTypeParameter: TypeParameters(emptyList()) -interface TestCaseGenerator { - fun init( - buildDir: Path, - classpath: String? = null, - dependencyPaths: String, - isCanceled: () -> Boolean = { false } - ) - - fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtTestCase -} - interface CodeGenerationSettingItem { val displayName: String val description: String @@ -1186,13 +1174,6 @@ fun isolateCommandLineArgumentsToArgumentFile(arguments: List): String { return argumentFile.absolutePath.let { "@$it" } } -interface UtService { - val displayName: String - val serviceProvider: T -} - -interface TestGeneratorService : UtService - private fun StringBuilder.appendOptional(name: String, value: Collection<*>) { if (value.isNotEmpty()) { append(", $name=$value") diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/CollectionWrappers.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/CollectionWrappers.kt index bf7d3e0f5a..e5c6558558 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/CollectionWrappers.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/CollectionWrappers.kt @@ -10,7 +10,6 @@ import org.utbot.engine.overrides.collections.UtHashSet import org.utbot.engine.overrides.collections.UtLinkedList import org.utbot.engine.pc.UtAddrExpression import org.utbot.engine.pc.UtExpression -import org.utbot.engine.pc.UtFalse import org.utbot.engine.pc.select import org.utbot.engine.symbolic.asHardConstraint import org.utbot.engine.z3.intValue @@ -26,7 +25,7 @@ import org.utbot.framework.plugin.api.UtNullModel import org.utbot.framework.plugin.api.UtReferenceModel import org.utbot.framework.plugin.api.UtStatementModel import org.utbot.framework.plugin.api.classId -import org.utbot.framework.plugin.api.graph +import org.utbot.framework.util.graph import org.utbot.framework.plugin.api.id import org.utbot.framework.plugin.api.util.booleanClassId import org.utbot.framework.plugin.api.util.constructorId diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt index 1fcd94dcea..4563012cb4 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/Traverser.kt @@ -89,13 +89,13 @@ import org.utbot.framework.plugin.api.FieldId import org.utbot.framework.plugin.api.MethodId import org.utbot.framework.plugin.api.UtMethod import org.utbot.framework.plugin.api.classId -import org.utbot.framework.plugin.api.graph import org.utbot.framework.plugin.api.id import org.utbot.framework.plugin.api.util.id import org.utbot.framework.plugin.api.util.jClass import org.utbot.framework.plugin.api.util.signature import org.utbot.framework.plugin.api.util.utContext import org.utbot.framework.util.executableId +import org.utbot.framework.util.graph import java.lang.reflect.ParameterizedType import kotlin.collections.plus import kotlin.collections.plusAssign diff --git a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt index 19811fb3c5..d42ba90f73 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt @@ -72,13 +72,13 @@ import org.utbot.framework.plugin.api.UtMethod import org.utbot.framework.plugin.api.UtNullModel import org.utbot.framework.plugin.api.UtOverflowFailure import org.utbot.framework.plugin.api.UtResult -import org.utbot.framework.plugin.api.graph -import org.utbot.framework.plugin.api.jimpleBody +import org.utbot.framework.util.graph import org.utbot.framework.plugin.api.onSuccess import org.utbot.framework.plugin.api.util.executableId import org.utbot.framework.plugin.api.util.id import org.utbot.framework.plugin.api.util.utContext import org.utbot.framework.plugin.api.util.description +import org.utbot.framework.util.jimpleBody import org.utbot.fuzzer.FallbackModelProvider import org.utbot.fuzzer.FuzzedMethodDescription import org.utbot.fuzzer.ModelProvider diff --git a/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt b/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt index b87f8dcb1e..f1bae2fb82 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt @@ -8,7 +8,7 @@ import org.utbot.framework.codegen.Junit5 import org.utbot.framework.codegen.NoStaticMocking import org.utbot.framework.codegen.StaticsMocking import org.utbot.framework.codegen.TestFramework -import org.utbot.framework.codegen.model.ModelBasedCodeGeneratorService +import org.utbot.framework.codegen.model.CodeGenerator import org.utbot.framework.concrete.UtConcreteExecutionData import org.utbot.framework.concrete.UtConcreteExecutionResult import org.utbot.framework.concrete.UtExecutionInstrumentation @@ -16,7 +16,7 @@ import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.CodegenLanguage import org.utbot.framework.plugin.api.MockFramework import org.utbot.framework.plugin.api.MockStrategyApi -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtExecution import org.utbot.framework.plugin.api.UtMethod import org.utbot.framework.plugin.api.UtPrimitiveModel @@ -81,10 +81,9 @@ object UtBotJavaApi { } return withUtContext(utContext) { - val testGenerator = ModelBasedCodeGeneratorService().serviceProvider.apply { + val testGenerator = CodeGenerator().apply { init( classUnderTest = classUnderTest, - params = mutableMapOf(), testFramework = testFramework, mockFramework = mockFramework, codegenLanguage = codegenLanguage, @@ -122,13 +121,13 @@ object UtBotJavaApi { val testCases: MutableList = mutableListOf() testCases.addAll(withUtContext(utContext) { - UtBotTestCaseGenerator + TestCaseGenerator .apply { init( FileUtil.isolateClassFiles(classUnderTest.kotlin).toPath(), classpath, dependencyClassPath ) } - .generateForSeveralMethods( + .generateTestCases( methodsForAutomaticGeneration.map { toUtMethod( it.methodToBeTestedFromUserInput, @@ -187,12 +186,12 @@ object UtBotJavaApi { } return withUtContext(UtContext(classUnderTest.classLoader)) { - UtBotTestCaseGenerator + TestCaseGenerator .apply { init( FileUtil.isolateClassFiles(classUnderTest.kotlin).toPath(), classpath, dependencyClassPath ) - }.generateForSeveralMethods( + }.generateTestCases( methodsForAutomaticGeneration.map { toUtMethod( it.methodToBeTestedFromUserInput, diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGeneratorService.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGeneratorService.kt deleted file mode 100644 index 9daffd9e51..0000000000 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGeneratorService.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.utbot.framework.codegen - -import org.utbot.framework.plugin.api.UtService - -interface CodeGeneratorService : UtService diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/TestCodeGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/TestCodeGenerator.kt deleted file mode 100644 index ca8b34b8f6..0000000000 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/TestCodeGenerator.kt +++ /dev/null @@ -1,35 +0,0 @@ -package org.utbot.framework.codegen - -import org.utbot.common.packageName -import org.utbot.framework.codegen.model.constructor.tree.TestsGenerationReport -import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.framework.plugin.api.MockFramework -import org.utbot.framework.plugin.api.UtMethod -import org.utbot.framework.plugin.api.UtTestCase - -interface TestCodeGenerator { - fun init( - classUnderTest: Class<*>, - params: MutableMap, List> = mutableMapOf(), - testFramework: TestFramework = Junit5, - mockFramework: MockFramework?, - staticsMocking: StaticsMocking, - forceStaticMocking: ForceStaticMocking, - generateWarningsForStaticMocking: Boolean, - codegenLanguage: CodegenLanguage = CodegenLanguage.JAVA, - parameterizedTestSource: ParametrizedTestSource = ParametrizedTestSource.DO_NOT_PARAMETRIZE, - runtimeExceptionTestsBehaviour: RuntimeExceptionTestsBehaviour = RuntimeExceptionTestsBehaviour.defaultItem, - hangingTestsTimeout: HangingTestsTimeout = HangingTestsTimeout(), - enableTestsTimeout: Boolean = true, - testClassPackageName: String = classUnderTest.packageName - ) - - fun generateAsString(testCases: Collection, testClassCustomName: String? = null): String - - fun generateAsStringWithTestReport( - testCases: Collection, - testClassCustomName: String? = null - ): TestsCodeWithTestReport -} - -data class TestsCodeWithTestReport(val generatedCode: String, val testsGenerationReport: TestsGenerationReport) diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/ModelBasedTestCodeGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt similarity index 73% rename from utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/ModelBasedTestCodeGenerator.kt rename to utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt index c96b88603e..6ef3f980fb 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/ModelBasedTestCodeGenerator.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/CodeGenerator.kt @@ -1,15 +1,15 @@ package org.utbot.framework.codegen.model +import org.utbot.common.packageName import org.utbot.framework.codegen.ForceStaticMocking import org.utbot.framework.codegen.HangingTestsTimeout import org.utbot.framework.codegen.ParametrizedTestSource import org.utbot.framework.codegen.RuntimeExceptionTestsBehaviour import org.utbot.framework.codegen.StaticsMocking -import org.utbot.framework.codegen.TestCodeGenerator import org.utbot.framework.codegen.TestFramework -import org.utbot.framework.codegen.TestsCodeWithTestReport import org.utbot.framework.codegen.model.constructor.context.CgContext import org.utbot.framework.codegen.model.constructor.tree.CgTestClassConstructor +import org.utbot.framework.codegen.model.constructor.tree.TestsGenerationReport import org.utbot.framework.codegen.model.tree.CgTestClassFile import org.utbot.framework.codegen.model.visitor.CgAbstractRenderer import org.utbot.framework.plugin.api.CodegenLanguage @@ -18,23 +18,23 @@ import org.utbot.framework.plugin.api.UtMethod import org.utbot.framework.plugin.api.UtTestCase import org.utbot.framework.plugin.api.util.id -class ModelBasedTestCodeGenerator : TestCodeGenerator { +class CodeGenerator { private lateinit var context: CgContext - override fun init( + fun init( classUnderTest: Class<*>, - params: MutableMap, List>, - testFramework: TestFramework, - mockFramework: MockFramework?, - staticsMocking: StaticsMocking, - forceStaticMocking: ForceStaticMocking, - generateWarningsForStaticMocking: Boolean, - codegenLanguage: CodegenLanguage, - parameterizedTestSource: ParametrizedTestSource, - runtimeExceptionTestsBehaviour: RuntimeExceptionTestsBehaviour, - hangingTestsTimeout: HangingTestsTimeout, - enableTestsTimeout: Boolean, - testClassPackageName: String + params: MutableMap, List> = mutableMapOf(), + testFramework: TestFramework = TestFramework.defaultItem, + mockFramework: MockFramework? = MockFramework.defaultItem, + staticsMocking: StaticsMocking = StaticsMocking.defaultItem, + forceStaticMocking: ForceStaticMocking = ForceStaticMocking.defaultItem, + generateWarningsForStaticMocking: Boolean = true, + codegenLanguage: CodegenLanguage = CodegenLanguage.defaultItem, + parameterizedTestSource: ParametrizedTestSource = ParametrizedTestSource.defaultItem, + runtimeExceptionTestsBehaviour: RuntimeExceptionTestsBehaviour = RuntimeExceptionTestsBehaviour.defaultItem, + hangingTestsTimeout: HangingTestsTimeout = HangingTestsTimeout(), + enableTestsTimeout: Boolean = true, + testClassPackageName: String = classUnderTest.packageName, ) { context = CgContext( classUnderTest = classUnderTest.id, @@ -56,13 +56,13 @@ class ModelBasedTestCodeGenerator : TestCodeGenerator { } //TODO: we support custom test class name only in utbot-online, probably support them in plugin as well - override fun generateAsString(testCases: Collection, testClassCustomName: String?): String = + fun generateAsString(testCases: Collection, testClassCustomName: String? = null): String = generateAsStringWithTestReport(testCases, testClassCustomName).generatedCode //TODO: we support custom test class name only in utbot-online, probably support them in plugin as well - override fun generateAsStringWithTestReport( + fun generateAsStringWithTestReport( testCases: Collection, - testClassCustomName: String? + testClassCustomName: String? = null, ): TestsCodeWithTestReport = withCustomContext(testClassCustomName) { context.withClassScope { @@ -95,3 +95,6 @@ class ModelBasedTestCodeGenerator : TestCodeGenerator { return renderer.toString() } } + +data class TestsCodeWithTestReport(val generatedCode: String, val testsGenerationReport: TestsGenerationReport) + diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/ModelBasedCodeGeneratorService.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/ModelBasedCodeGeneratorService.kt deleted file mode 100644 index 4feeddb15f..0000000000 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/ModelBasedCodeGeneratorService.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.utbot.framework.codegen.model - -import org.utbot.framework.codegen.CodeGeneratorService -import org.utbot.framework.codegen.TestCodeGenerator - -class ModelBasedCodeGeneratorService : CodeGeneratorService { - override val displayName: String = "Model based code generator" - override val serviceProvider: TestCodeGenerator = ModelBasedTestCodeGenerator() -} \ No newline at end of file diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/SymbolicEngineTestGeneratorService.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/SymbolicEngineTestGeneratorService.kt deleted file mode 100644 index 2f65896fa5..0000000000 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/SymbolicEngineTestGeneratorService.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.utbot.framework.plugin.api - -class SymbolicEngineTestGeneratorService : TestGeneratorService { - override val displayName: String = "Symbolic engine" - override val serviceProvider: TestCaseGenerator = UtBotTestCaseGenerator -} 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/TestCaseGenerator.kt similarity index 82% rename from utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGenerator.kt rename to utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/TestCaseGenerator.kt index d9229b324c..542a39f6c8 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/TestCaseGenerator.kt @@ -6,10 +6,7 @@ import org.utbot.common.runBlockingWithCancellationPredicate import org.utbot.common.runIgnoringCancellationException import org.utbot.common.trace import org.utbot.engine.EngineController -import org.utbot.engine.MockStrategy import org.utbot.engine.Mocker -import org.utbot.engine.jimpleBody -import org.utbot.engine.pureJavaSignature import org.utbot.framework.TestSelectionStrategyType import org.utbot.framework.UtSettings import org.utbot.framework.UtSettings.checkSolverTimeoutMillis @@ -24,14 +21,16 @@ import org.utbot.framework.minimization.minimizeTestCase import org.utbot.framework.plugin.api.util.UtContext import org.utbot.framework.plugin.api.util.id import org.utbot.framework.plugin.api.util.intArrayClassId -import org.utbot.framework.plugin.api.util.signature import org.utbot.framework.plugin.api.util.utContext import org.utbot.framework.plugin.api.util.withUtContext +import org.utbot.framework.util.jimpleBody +import org.utbot.framework.util.runSoot +import org.utbot.framework.util.toModel import org.utbot.instrumentation.ConcreteExecutor import org.utbot.instrumentation.warmup.Warmup import java.io.File import java.nio.file.Path -import java.util.IdentityHashMap +import java.util.* import kotlin.coroutines.cancellation.CancellationException import kotlin.math.min import kotlin.reflect.KCallable @@ -48,11 +47,8 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.yield import mu.KotlinLogging import org.utbot.engine.UtBotSymbolicEngine -import soot.Scene -import soot.jimple.JimpleBody -import soot.toolkits.graph.ExceptionalUnitGraph -object UtBotTestCaseGenerator : TestCaseGenerator { +object TestCaseGenerator { private val logger = KotlinLogging.logger {} private val timeoutLogger = KotlinLogging.logger(logger.name + ".timeout") @@ -66,25 +62,12 @@ object UtBotTestCaseGenerator : TestCaseGenerator { private var previousTimestamp: Long? = null private var dependencyPaths: String = "" - override fun init( - buildDir: Path, - classpath: String?, - dependencyPaths: String, - isCanceled: () -> Boolean - ) = init( - buildDir, - classpath, - dependencyPaths, - engineActions = mutableListOf(), - isCanceled - ) - fun init( buildDir: Path, classpath: String?, dependencyPaths: String, - engineActions: MutableList<(UtBotSymbolicEngine) -> Unit>, - isCanceled: () -> Boolean + engineActions: MutableList<(UtBotSymbolicEngine) -> Unit> = mutableListOf(), + isCanceled: () -> Boolean = { false }, ) { this.isCanceled = isCanceled this.engineActions = engineActions @@ -96,7 +79,6 @@ object UtBotTestCaseGenerator : TestCaseGenerator { //optimization: maxLastModifiedRecursivelyMillis can take time val timestamp = if (UtSettings.classfilesCanChange) maxLastModifiedRecursivelyMillis(buildDir, classpath) else 0 - if (buildDir == previousBuildDir && classpath == previousClasspath && timestamp == previousTimestamp) { logger.info { "Ignoring soot initialization because parameters are the same as on previous initialization" } return @@ -135,128 +117,26 @@ object UtBotTestCaseGenerator : TestCaseGenerator { } } - private fun constructExecutionsForWarmup(): Sequence, UtConcreteExecutionData>> = - UtModelConstructor(IdentityHashMap()).run { - sequenceOf( - Warmup::doWarmup1 to UtConcreteExecutionData( - EnvironmentModels( - construct(Warmup(5), Warmup::class.java.id), - listOf(construct(Warmup(1), Warmup::class.java.id)), - emptyMap() - ), emptyList() - ), - Warmup::doWarmup2 to UtConcreteExecutionData( - EnvironmentModels( - construct(Warmup(1), Warmup::class.java.id), - listOf(construct(intArrayOf(1, 2, 3), intArrayClassId)), - emptyMap() - ), emptyList() - ), - Warmup::doWarmup2 to UtConcreteExecutionData( - EnvironmentModels( - construct(Warmup(1), Warmup::class.java.id), - listOf(construct(intArrayOf(1, 2, 3, 4, 5, 6), intArrayClassId)), - emptyMap() - ), emptyList() - ), - ) - } - - private val classpathForEngine: String - get() = previousBuildDir!!.toString() + (previousClasspath?.let { File.pathSeparator + it } ?: "") - - private fun maxLastModifiedRecursivelyMillis(buildDir: Path, classpath: String?): Long { - val paths = mutableListOf() - paths += buildDir.toFile() - if (classpath != null) { - paths += classpath.split(File.pathSeparatorChar).map { File(it) } + fun minimizeExecutions(executions: List): List = + if (UtSettings.testMinimizationStrategyType == TestSelectionStrategyType.DO_NOT_MINIMIZE_STRATEGY) { + executions + } else { + minimizeTestCase(executions) { it.result::class.java } } - return FileUtil.maxLastModifiedRecursivelyMillis(paths) - } @Throws(CancellationException::class) - fun generateAsync( + fun generateTestCasesAsync( controller: EngineController, method: UtMethod<*>, mockStrategy: MockStrategyApi, chosenClassesToMockAlways: Set = Mocker.javaDefaultClasses.mapTo(mutableSetOf()) { it.id }, executionTimeEstimator: ExecutionTimeEstimator = ExecutionTimeEstimator(utBotGenerationTimeoutInMillis, 1) ): Flow { - val engine = createSymbolicEngine( - controller, - method, - mockStrategy, - chosenClassesToMockAlways, - executionTimeEstimator - ) + val engine = createSymbolicEngine(controller, method, mockStrategy, chosenClassesToMockAlways, executionTimeEstimator) return createDefaultFlow(engine) } - private fun createSymbolicEngine( - controller: EngineController, - method: UtMethod<*>, - mockStrategy: MockStrategyApi, - chosenClassesToMockAlways: Set, - executionTimeEstimator: ExecutionTimeEstimator - ): UtBotSymbolicEngine { - // TODO: create classLoader from buildDir/classpath and migrate from UtMethod to MethodId? - logger.debug("Starting symbolic execution for $method --$mockStrategy--") - return UtBotSymbolicEngine( - controller, - method, - classpathForEngine, - dependencyPaths = dependencyPaths, - mockStrategy = apiToModel(mockStrategy), - chosenClassesToMockAlways = chosenClassesToMockAlways, - solverTimeoutInMillis = executionTimeEstimator.updatedSolverCheckTimeoutMillis - ) - } - - private fun createDefaultFlow(engine: UtBotSymbolicEngine): Flow { - var flow = engine.traverse() - if (UtSettings.useFuzzing) { - flow = flowOf( - engine.fuzzing(System.currentTimeMillis() + UtSettings.fuzzingTimeoutInMillis), - flow, - ).flattenConcat() - } - return flow - } - - // CONFLUENCE:The+UtBot+Java+timeouts - - class ExecutionTimeEstimator(val userTimeout: Long, methodsUnderTestNumber: Int) { - // Cut the timeout from the user in two halves - private val halfTimeUserExpectsToWaitInMillis = userTimeout / 2 - - // If the half is too much for concrete execution, decrease the concrete timeout - var concreteExecutionBudgetInMillis = - min(halfTimeUserExpectsToWaitInMillis, 300L * methodsUnderTestNumber) - - // The symbolic execution time is the reminder but not longer than checkSolverTimeoutMillis times methods number - val symbolicExecutionTimeout = userTimeout - concreteExecutionBudgetInMillis - - //Allow traverse at least one method for the symbolic execution timeout - val timeslotForOneToplevelMethodTraversalInMillis = - symbolicExecutionTimeout / (methodsUnderTestNumber * 2) - - // Axillary field - private val symbolicExecutionTimePerMethod = (symbolicExecutionTimeout / methodsUnderTestNumber).toInt() - - // Now we calculate the solver timeout. Each method is supposed to get some time in worst-case scenario - val updatedSolverCheckTimeoutMillis = if (symbolicExecutionTimePerMethod < checkSolverTimeoutMillis) - symbolicExecutionTimePerMethod else checkSolverTimeoutMillis - - init { - // Update the concrete execution time, if symbolic execution time is small - // because of UtSettings.checkSolverTimeoutMillis - concreteExecutionBudgetInMillis = userTimeout - symbolicExecutionTimeout - require(symbolicExecutionTimeout > 10) - require(concreteExecutionBudgetInMillis > 10) - } - } - - fun generateForSeveralMethods( + fun generateTestCases( methods: List>, mockStrategy: MockStrategyApi, chosenClassesToMockAlways: Set = Mocker.javaDefaultClasses.mapTo(mutableSetOf()) { it.id }, @@ -347,6 +227,109 @@ object UtBotTestCaseGenerator : TestCaseGenerator { } } + private fun constructExecutionsForWarmup(): Sequence, UtConcreteExecutionData>> = + UtModelConstructor(IdentityHashMap()).run { + sequenceOf( + Warmup::doWarmup1 to UtConcreteExecutionData( + EnvironmentModels( + construct(Warmup(5), Warmup::class.java.id), + listOf(construct(Warmup(1), Warmup::class.java.id)), + emptyMap() + ), emptyList() + ), + Warmup::doWarmup2 to UtConcreteExecutionData( + EnvironmentModels( + construct(Warmup(1), Warmup::class.java.id), + listOf(construct(intArrayOf(1, 2, 3), intArrayClassId)), + emptyMap() + ), emptyList() + ), + Warmup::doWarmup2 to UtConcreteExecutionData( + EnvironmentModels( + construct(Warmup(1), Warmup::class.java.id), + listOf(construct(intArrayOf(1, 2, 3, 4, 5, 6), intArrayClassId)), + emptyMap() + ), emptyList() + ), + ) + } + + private val classpathForEngine: String + get() = previousBuildDir!!.toString() + (previousClasspath?.let { File.pathSeparator + it } ?: "") + + private fun maxLastModifiedRecursivelyMillis(buildDir: Path, classpath: String?): Long { + val paths = mutableListOf() + paths += buildDir.toFile() + if (classpath != null) { + paths += classpath.split(File.pathSeparatorChar).map { File(it) } + } + return FileUtil.maxLastModifiedRecursivelyMillis(paths) + } + + private fun createSymbolicEngine( + controller: EngineController, + method: UtMethod<*>, + mockStrategyApi: MockStrategyApi, + chosenClassesToMockAlways: Set, + executionTimeEstimator: ExecutionTimeEstimator + ): UtBotSymbolicEngine { + // TODO: create classLoader from buildDir/classpath and migrate from UtMethod to MethodId? + logger.debug("Starting symbolic execution for $method --$mockStrategyApi--") + return UtBotSymbolicEngine( + controller, + method, + classpathForEngine, + dependencyPaths = dependencyPaths, + mockStrategy = mockStrategyApi.toModel(), + chosenClassesToMockAlways = chosenClassesToMockAlways, + solverTimeoutInMillis = executionTimeEstimator.updatedSolverCheckTimeoutMillis + ) + } + + private fun createDefaultFlow(engine: UtBotSymbolicEngine): Flow { + var flow = engine.traverse() + if (UtSettings.useFuzzing) { + flow = flowOf( + engine.fuzzing(System.currentTimeMillis() + UtSettings.fuzzingTimeoutInMillis), + flow, + ).flattenConcat() + } + return flow + } + + // CONFLUENCE:The+UtBot+Java+timeouts + + class ExecutionTimeEstimator(val userTimeout: Long, methodsUnderTestNumber: Int) { + // Cut the timeout from the user in two halves + private val halfTimeUserExpectsToWaitInMillis = userTimeout / 2 + + // If the half is too much for concrete execution, decrease the concrete timeout + var concreteExecutionBudgetInMillis = + min(halfTimeUserExpectsToWaitInMillis, 300L * methodsUnderTestNumber) + + // The symbolic execution time is the reminder but not longer than checkSolverTimeoutMillis times methods number + val symbolicExecutionTimeout = userTimeout - concreteExecutionBudgetInMillis + + //Allow traverse at least one method for the symbolic execution timeout + val timeslotForOneToplevelMethodTraversalInMillis = + symbolicExecutionTimeout / (methodsUnderTestNumber * 2) + + // Axillary field + private val symbolicExecutionTimePerMethod = (symbolicExecutionTimeout / methodsUnderTestNumber).toInt() + + // Now we calculate the solver timeout. Each method is supposed to get some time in worst-case scenario + val updatedSolverCheckTimeoutMillis = if (symbolicExecutionTimePerMethod < checkSolverTimeoutMillis) + symbolicExecutionTimePerMethod else checkSolverTimeoutMillis + + init { + // Update the concrete execution time, if symbolic execution time is small + // because of UtSettings.checkSolverTimeoutMillis + concreteExecutionBudgetInMillis = userTimeout - symbolicExecutionTimeout + require(symbolicExecutionTimeout > 10) + require(concreteExecutionBudgetInMillis > 10) + } + } + private fun updateLifecycle( executionStartInMillis: Long, executionTimeEstimator: ExecutionTimeEstimator, @@ -375,63 +358,6 @@ object UtBotTestCaseGenerator : TestCaseGenerator { } } - override fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtTestCase { - logger.trace { "UtSettings:${System.lineSeparator()}" + UtSettings.toString() } - - if (isCanceled()) return UtTestCase(method) - - val executions = mutableListOf() - val errors = mutableMapOf() - - runIgnoringCancellationException { - runBlockingWithCancellationPredicate(isCanceled) { - generateAsync(EngineController(), method, mockStrategy).collect { - when (it) { - is UtExecution -> executions += it - is UtError -> errors.merge(it.description, 1, Int::plus) - } - } - } - } - - val minimizedExecutions = minimizeExecutions(executions) - return UtTestCase(method, minimizedExecutions, jimpleBody(method), errors) - } - - - private fun minimizeExecutions(executions: List): List = - if (UtSettings.testMinimizationStrategyType == TestSelectionStrategyType.DO_NOT_MINIMIZE_STRATEGY) { - executions - } else { - minimizeTestCase(executions) { it.result::class.java } - } - - - fun apiToModel(mockStrategyApi: MockStrategyApi): MockStrategy = - when (mockStrategyApi) { - MockStrategyApi.NO_MOCKS -> MockStrategy.NO_MOCKS - MockStrategyApi.OTHER_PACKAGES -> MockStrategy.OTHER_PACKAGES - MockStrategyApi.OTHER_CLASSES -> MockStrategy.OTHER_CLASSES - else -> error("Cannot map API Mock Strategy model to Engine model: $mockStrategyApi") - } - -} - -fun graph(method: UtMethod<*>): ExceptionalUnitGraph { - val methodBody = jimpleBody(method) - return methodBody.graph() -} - -fun jimpleBody(method: UtMethod<*>): JimpleBody { - val className = method.clazz.java.name - val clazz = Scene.v().classes.singleOrNull { it.name == className } - ?: error("No such $className found in the Scene") - val signature = method.callable.signature - val sootMethod = clazz.methods.singleOrNull { it.pureJavaSignature == signature } - ?: error("No such $signature found") - - return sootMethod.jimpleBody() } -fun JimpleBody.graph() = ExceptionalUnitGraph(this) diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt index 5673f5f630..5b4bb5bab0 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt @@ -2,8 +2,8 @@ package org.utbot.framework.plugin.sarif import org.utbot.framework.codegen.ForceStaticMocking import org.utbot.framework.codegen.NoStaticMocking -import org.utbot.framework.codegen.model.ModelBasedTestCodeGenerator -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.codegen.model.CodeGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtTestCase import org.utbot.sarif.SarifReport import org.utbot.sarif.SourceFindingStrategy @@ -66,11 +66,11 @@ class GenerateTestsAndSarifReportFacade( } private fun initializeEngine(classPath: String, workingDirectory: Path) { - UtBotTestCaseGenerator.init(workingDirectory, classPath, dependencyPaths) { false } + TestCaseGenerator.init(workingDirectory, classPath, dependencyPaths) } private fun generateTestCases(targetClass: TargetClassWrapper, workingDirectory: Path): List = - UtBotTestCaseGenerator.generateForSeveralMethods( + TestCaseGenerator.generateTestCases( targetClass.targetMethods(), sarifProperties.mockStrategy, sarifProperties.classesToMockAlways, @@ -84,9 +84,10 @@ class GenerateTestsAndSarifReportFacade( .generateAsString(testCases, targetClass.testsCodeFile.nameWithoutExtension) private fun initializeCodeGenerator(targetClass: TargetClassWrapper) = - ModelBasedTestCodeGenerator().apply { + CodeGenerator().apply { val isNoStaticMocking = sarifProperties.staticsMocking is NoStaticMocking val isForceStaticMocking = sarifProperties.forceStaticMocking == ForceStaticMocking.FORCE + init( classUnderTest = targetClass.classUnderTest.java, testFramework = sarifProperties.testFramework, diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/util/MockStrategyUtils.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/util/MockStrategyUtils.kt new file mode 100644 index 0000000000..e281a4902e --- /dev/null +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/util/MockStrategyUtils.kt @@ -0,0 +1,12 @@ +package org.utbot.framework.util + +import org.utbot.engine.MockStrategy +import org.utbot.framework.plugin.api.MockStrategyApi + +fun MockStrategyApi.toModel(): MockStrategy = + when (this) { + MockStrategyApi.NO_MOCKS -> MockStrategy.NO_MOCKS + MockStrategyApi.OTHER_PACKAGES -> MockStrategy.OTHER_PACKAGES + MockStrategyApi.OTHER_CLASSES -> MockStrategy.OTHER_CLASSES + else -> error("Cannot map API Mock Strategy model to Engine model: $this") + } \ No newline at end of file diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/SootUtils.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt similarity index 89% rename from utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/SootUtils.kt rename to utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt index a4be349dce..65953d900d 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/api/SootUtils.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt @@ -1,8 +1,9 @@ -package org.utbot.framework.plugin.api +package org.utbot.framework.util import org.utbot.api.mock.UtMock import org.utbot.common.FileUtil import org.utbot.engine.UtNativeStringWrapper +import org.utbot.engine.jimpleBody import org.utbot.engine.overrides.Boolean import org.utbot.engine.overrides.Byte import org.utbot.engine.overrides.Character @@ -36,6 +37,9 @@ import org.utbot.engine.overrides.collections.AbstractCollection import org.utbot.engine.overrides.stream.Arrays import org.utbot.engine.overrides.stream.Stream import org.utbot.engine.overrides.stream.UtStream +import org.utbot.engine.pureJavaSignature +import org.utbot.framework.plugin.api.UtMethod +import org.utbot.framework.plugin.api.util.signature import java.io.File import java.nio.file.Path import kotlin.reflect.KClass @@ -43,7 +47,9 @@ import soot.G import soot.PackManager import soot.Scene import soot.SootClass +import soot.jimple.JimpleBody import soot.options.Options +import soot.toolkits.graph.ExceptionalUnitGraph /** Convert code to Jimple @@ -86,6 +92,16 @@ fun runSoot(buildDir: Path, classpath: String?) { } } +fun JimpleBody.graph() = ExceptionalUnitGraph(this) + +fun jimpleBody(method: UtMethod<*>): JimpleBody { + val clazz = Scene.v().classes.single { it.name == method.clazz.java.name } + val signature = method.callable.signature + val sootMethod = clazz.methods.single { it.pureJavaSignature == signature } + + return sootMethod.jimpleBody() +} + private fun addBasicClasses(vararg classes: KClass<*>) { classes.forEach { Scene.v().addBasicClass(it.qualifiedName, SootClass.BODIES) diff --git a/utbot-framework/src/test/java/org/utbot/examples/manual/KotlinWrappers.kt b/utbot-framework/src/test/java/org/utbot/examples/manual/KotlinWrappers.kt index 4e0e761fa0..29566f0138 100644 --- a/utbot-framework/src/test/java/org/utbot/examples/manual/KotlinWrappers.kt +++ b/utbot-framework/src/test/java/org/utbot/examples/manual/KotlinWrappers.kt @@ -14,7 +14,7 @@ object SootUtils { val buildDirPath = buildDir.toPath() if (buildDirPath != previousBuildDir) { - org.utbot.framework.plugin.api.runSoot(buildDirPath, null) + org.utbot.framework.util.runSoot(buildDirPath, null) previousBuildDir = buildDirPath } } diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/CodeTestCaseGeneratorTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/CodeGenerationIntegrationTest.kt similarity index 97% rename from utbot-framework/src/test/kotlin/org/utbot/examples/CodeTestCaseGeneratorTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/CodeGenerationIntegrationTest.kt index 900aa0d896..41ac541be4 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/CodeTestCaseGeneratorTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/CodeGenerationIntegrationTest.kt @@ -4,7 +4,7 @@ import org.utbot.common.FileUtil import org.utbot.common.packageName import org.utbot.common.withAccessibility import org.utbot.framework.UtSettings -import org.utbot.framework.codegen.BaseTestCodeGeneratorPipeline.Companion.defaultCodegenPipeline +import org.utbot.framework.codegen.TestCodeGeneratorPipeline.Companion.defaultCodegenPipeline import org.utbot.framework.codegen.ClassStages import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.codegen.ExecutionStatus @@ -32,8 +32,8 @@ import org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor @TestInstance(TestInstance.Lifecycle.PER_CLASS) @TestMethodOrder(MethodOrderer.OrderAnnotation::class) -@ExtendWith(CodeTestCaseGeneratorTest.Companion.ReadRunningTestsNumberBeforeAllTestsCallback::class) -abstract class CodeTestCaseGeneratorTest( +@ExtendWith(CodeGenerationIntegrationTest.Companion.ReadRunningTestsNumberBeforeAllTestsCallback::class) +abstract class CodeGenerationIntegrationTest( private val testClass: KClass<*>, private var testCodeGeneration: Boolean = true, private val languagesLastStages: List = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/TestSpecificTestCaseGenerator.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/TestSpecificTestCaseGenerator.kt new file mode 100644 index 0000000000..692ee02d77 --- /dev/null +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/TestSpecificTestCaseGenerator.kt @@ -0,0 +1,42 @@ +package org.utbot.examples + +import kotlinx.coroutines.flow.collect +import mu.KotlinLogging +import org.utbot.common.runBlockingWithCancellationPredicate +import org.utbot.common.runIgnoringCancellationException +import org.utbot.engine.EngineController +import org.utbot.framework.UtSettings +import org.utbot.framework.plugin.api.MockStrategyApi +import org.utbot.framework.plugin.api.TestCaseGenerator +import org.utbot.framework.plugin.api.UtError +import org.utbot.framework.plugin.api.UtExecution +import org.utbot.framework.plugin.api.UtMethod +import org.utbot.framework.plugin.api.UtTestCase +import org.utbot.framework.util.jimpleBody + +object TestSpecificTestCaseGenerator { + private val logger = KotlinLogging.logger {} + + fun generate(method: UtMethod<*>, mockStrategy: MockStrategyApi): UtTestCase { + logger.trace { "UtSettings:${System.lineSeparator()}" + UtSettings.toString() } + + if (TestCaseGenerator.isCanceled()) return UtTestCase(method) + + val executions = mutableListOf() + val errors = mutableMapOf() + + runIgnoringCancellationException { + runBlockingWithCancellationPredicate(TestCaseGenerator.isCanceled) { + TestCaseGenerator.generateTestCasesAsync(EngineController(), method, mockStrategy).collect { + when (it) { + is UtExecution -> executions += it + is UtError -> errors.merge(it.description, 1, Int::plus) + } + } + } + } + + val minimizedExecutions = TestCaseGenerator.minimizeExecutions(executions) + return UtTestCase(method, minimizedExecutions, jimpleBody(method), errors) + } +} \ No newline at end of file diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/AbstractModelBasedTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/UtModelChecker.kt similarity index 95% rename from utbot-framework/src/test/kotlin/org/utbot/examples/AbstractModelBasedTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/UtModelChecker.kt index cac05041c3..ece09a5275 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/AbstractModelBasedTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/UtModelChecker.kt @@ -15,7 +15,7 @@ import org.utbot.framework.plugin.api.FieldId import org.utbot.framework.plugin.api.MockStrategyApi import org.utbot.framework.plugin.api.MockStrategyApi.NO_MOCKS import org.utbot.framework.plugin.api.UtAssembleModel -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtCompositeModel import org.utbot.framework.plugin.api.UtDirectSetFieldModel import org.utbot.framework.plugin.api.UtExecution @@ -39,14 +39,14 @@ import kotlin.reflect.KFunction2 import kotlin.reflect.KFunction3 import org.junit.jupiter.api.Assertions.assertTrue -internal abstract class AbstractModelBasedTest( +internal abstract class UtModelChecker( testClass: KClass<*>, testCodeGeneration: Boolean = true, languagePipelines: List = listOf( CodeGenerationLanguageLastStage(CodegenLanguage.JAVA), CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN) ) -) : CodeTestCaseGeneratorTest(testClass, testCodeGeneration, languagePipelines) { +) : CodeGenerationIntegrationTest(testClass, testCodeGeneration, languagePipelines) { protected fun check( method: KFunction2<*, *, *>, branches: ExecutionsNumberMatcher, @@ -136,8 +136,8 @@ internal abstract class AbstractModelBasedTest( buildDir = findPathToClassFiles(classLocation) previousClassLocation = classLocation } - UtBotTestCaseGenerator.init(buildDir, classpath = null, dependencyPaths = System.getProperty("java.class.path")) - return UtBotTestCaseGenerator.generate(method, mockStrategy) + TestCaseGenerator.init(buildDir, classpath = null, dependencyPaths = System.getProperty("java.class.path")) + return TestSpecificTestCaseGenerator.generate(method, mockStrategy) } protected inline fun UtExecutionResult.isException(): Boolean = exceptionOrNull() is T diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/AbstractTestCaseGeneratorTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/UtTestCaseChecker.kt similarity index 99% rename from utbot-framework/src/test/kotlin/org/utbot/examples/AbstractTestCaseGeneratorTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/UtTestCaseChecker.kt index 2b4e941d71..fe5315e4c7 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/AbstractTestCaseGeneratorTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/UtTestCaseChecker.kt @@ -2,11 +2,14 @@ package org.utbot.examples +import mu.KotlinLogging +import org.junit.jupiter.api.Assertions.assertTrue import org.utbot.common.ClassLocation import org.utbot.common.FileUtil.clearTempDirectory import org.utbot.common.FileUtil.findPathToClassFiles import org.utbot.common.FileUtil.locateClass import org.utbot.engine.prettify +import org.utbot.framework.PathSelectorType import org.utbot.framework.TestSelectionStrategyType import org.utbot.framework.UtSettings import org.utbot.framework.UtSettings.checkCoverageInCodeGenerationTests @@ -14,11 +17,11 @@ import org.utbot.framework.UtSettings.daysLimitForTempFiles import org.utbot.framework.UtSettings.testDisplayName import org.utbot.framework.UtSettings.testName import org.utbot.framework.UtSettings.testSummary -import org.utbot.framework.codegen.BaseTestCodeGeneratorPipeline import org.utbot.framework.codegen.ClassStages import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.codegen.ExecutionStatus import org.utbot.framework.codegen.StageStatusCheck +import org.utbot.framework.codegen.TestCodeGeneratorPipeline import org.utbot.framework.codegen.TestExecution import org.utbot.framework.coverage.Coverage import org.utbot.framework.coverage.counters @@ -39,7 +42,7 @@ import org.utbot.framework.plugin.api.MockStrategyApi import org.utbot.framework.plugin.api.MockStrategyApi.NO_MOCKS import org.utbot.framework.plugin.api.ObjectMockTarget import org.utbot.framework.plugin.api.ParameterMockTarget -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtCompositeModel import org.utbot.framework.plugin.api.UtConcreteValue import org.utbot.framework.plugin.api.UtInstrumentation @@ -52,6 +55,7 @@ import org.utbot.framework.plugin.api.UtValueExecution import org.utbot.framework.plugin.api.util.UtContext import org.utbot.framework.plugin.api.util.executableId import org.utbot.framework.plugin.api.util.withUtContext +import org.utbot.framework.util.jimpleBody import org.utbot.framework.util.toValueTestCase import org.utbot.summary.summarize import java.io.File @@ -65,21 +69,17 @@ import kotlin.reflect.KFunction2 import kotlin.reflect.KFunction3 import kotlin.reflect.KFunction4 import kotlin.reflect.KFunction5 -import mu.KotlinLogging -import org.junit.jupiter.api.Assertions.assertTrue -import org.utbot.framework.PathSelectorType -import org.utbot.framework.plugin.api.jimpleBody val logger = KotlinLogging.logger {} -abstract class AbstractTestCaseGeneratorTest( +abstract class UtTestCaseChecker( testClass: KClass<*>, testCodeGeneration: Boolean = true, languagePipelines: List = listOf( CodeGenerationLanguageLastStage(CodegenLanguage.JAVA), CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN) ) -) : CodeTestCaseGeneratorTest(testClass, testCodeGeneration, languagePipelines) { +) : CodeGenerationIntegrationTest(testClass, testCodeGeneration, languagePipelines) { // contains already analyzed by the engine methods private val analyzedMethods: MutableMap = mutableMapOf() @@ -2310,7 +2310,7 @@ abstract class AbstractTestCaseGeneratorTest( ) val classStages = listOf(ClassStages(testClass, stageStatusCheck, listOf(testCase))) - BaseTestCodeGeneratorPipeline(testFrameworkConfiguration).runClassesCodeGenerationTests(classStages) + TestCodeGeneratorPipeline(testFrameworkConfiguration).runClassesCodeGenerationTests(classStages) } } } @@ -2493,8 +2493,8 @@ abstract class AbstractTestCaseGeneratorTest( mockStrategy: MockStrategyApi, additionalDependenciesClassPath: String ): UtTestCase { - UtBotTestCaseGenerator.init(buildDir, additionalDependenciesClassPath, System.getProperty("java.class.path")) - return UtBotTestCaseGenerator.generate(method, mockStrategy) + TestCaseGenerator.init(buildDir, additionalDependenciesClassPath, System.getProperty("java.class.path")) + return TestSpecificTestCaseGenerator.generate(method, mockStrategy) } fun executionsModel( @@ -2504,9 +2504,9 @@ abstract class AbstractTestCaseGeneratorTest( ): UtTestCase { val additionalDependenciesClassPath = computeAdditionalDependenciesClasspathAndBuildDir(method, additionalDependencies) - UtBotTestCaseGenerator.init(buildDir, additionalDependenciesClassPath, System.getProperty("java.class.path")) + TestCaseGenerator.init(buildDir, additionalDependenciesClassPath, System.getProperty("java.class.path")) withUtContext(UtContext(method.clazz.java.classLoader)) { - return UtBotTestCaseGenerator.generate(method, mockStrategy) + return TestSpecificTestCaseGenerator.generate(method, mockStrategy) } } diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt index e3e36855f1..61dbde7e36 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.algorithms -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.isException import org.utbot.framework.plugin.api.DocCodeStmt @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.DocRegularStmt import org.utbot.framework.plugin.api.DocStatement import org.junit.jupiter.api.Test -class BinarySearchTest : AbstractTestCaseGeneratorTest(testClass = BinarySearch::class,) { +class BinarySearchTest : UtTestCaseChecker(testClass = BinarySearch::class,) { @Test fun testLeftBinarySearch() { val fullSummary = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt index 0b8d288089..6d7a40b201 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.algorithms -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.algorithms.CorrectBracketSequences.isBracket import org.utbot.examples.algorithms.CorrectBracketSequences.isOpen import org.utbot.examples.eq @@ -14,7 +14,7 @@ import org.utbot.framework.plugin.api.DocPreTagStatement import org.utbot.framework.plugin.api.DocRegularStmt import org.junit.jupiter.api.Test -internal class CorrectBracketSequencesTest : AbstractTestCaseGeneratorTest( +internal class CorrectBracketSequencesTest : UtTestCaseChecker( testClass = CorrectBracketSequences::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/GraphTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/GraphTest.kt index 3a7fadcb7b..fa97847427 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/GraphTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/GraphTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.algorithms -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.isException import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test -internal class GraphTest : AbstractTestCaseGeneratorTest(testClass = GraphExample::class) { +internal class GraphTest : UtTestCaseChecker(testClass = GraphExample::class) { @Test @Tag("slow") fun testRunFindCycle() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt index 7424258430..412fa92a60 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.algorithms -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.ge import org.utbot.examples.ignoreExecutionsNumber @@ -12,7 +12,7 @@ import org.utbot.framework.plugin.api.DocRegularStmt import org.utbot.framework.plugin.api.MockStrategyApi import org.junit.jupiter.api.Test -internal class SortTest : AbstractTestCaseGeneratorTest(testClass = Sort::class) { +internal class SortTest : UtTestCaseChecker(testClass = Sort::class) { @Test fun testQuickSort() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/LombokAnnotationTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/LombokAnnotationTest.kt index f27e4cc91c..2988979ec6 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/LombokAnnotationTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/LombokAnnotationTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.annotations -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.annotations.lombok.EnumWithAnnotations import org.utbot.examples.annotations.lombok.EnumWithoutAnnotations @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test * (see, i.e. https://stackoverflow.com/questions/44584487/improve-lombok-data-code-coverage) * and Lombok code is considered to be already tested itself. */ -class LombokAnnotationTest : AbstractTestCaseGeneratorTest(testClass = EnumWithAnnotations::class) { +class LombokAnnotationTest : UtTestCaseChecker(testClass = EnumWithAnnotations::class) { @Test fun testGetterWithAnnotations() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/NotNullAnnotationTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/NotNullAnnotationTest.kt index b22b46285a..00510ea5a5 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/NotNullAnnotationTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/annotations/NotNullAnnotationTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.annotations -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class NotNullAnnotationTest : AbstractTestCaseGeneratorTest(testClass = NotNullAnnotation::class) { +internal class NotNullAnnotationTest : UtTestCaseChecker(testClass = NotNullAnnotation::class) { @Test fun testDoesNotThrowNPE() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfArraysTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfArraysTest.kt index e7c660e426..91837bed92 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfArraysTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfArraysTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.arrays -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.atLeast import org.utbot.examples.casts.ColoredPoint @@ -11,7 +11,7 @@ import org.utbot.examples.withoutMinimization import org.junit.jupiter.api.Test @Suppress("NestedLambdaShadowedImplicitParameter") -internal class ArrayOfArraysTest : AbstractTestCaseGeneratorTest(testClass = ArrayOfArrays::class) { +internal class ArrayOfArraysTest : UtTestCaseChecker(testClass = ArrayOfArrays::class) { @Test fun testDefaultValues() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfObjectsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfObjectsTest.kt index c89c8b17d4..478b28a4f9 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfObjectsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArrayOfObjectsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.arrays -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.atLeast import org.utbot.examples.between @@ -13,7 +13,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class ArrayOfObjectsTest : AbstractTestCaseGeneratorTest( +internal class ArrayOfObjectsTest : UtTestCaseChecker( testClass = ArrayOfObjects::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArraysOverwriteValueTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArraysOverwriteValueTest.kt index d73246a0c5..bdd1bc7471 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArraysOverwriteValueTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/ArraysOverwriteValueTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.arrays -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -class ArraysOverwriteValueTest : AbstractTestCaseGeneratorTest( +class ArraysOverwriteValueTest : UtTestCaseChecker( testClass = ArraysOverwriteValue::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/FinalStaticFieldArrayTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/FinalStaticFieldArrayTest.kt index 624d27766e..d8a3265da1 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/FinalStaticFieldArrayTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/FinalStaticFieldArrayTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.arrays -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.ignoreExecutionsNumber import org.junit.jupiter.api.Test -internal class FinalStaticFieldArrayTest : AbstractTestCaseGeneratorTest(testClass = FinalStaticFieldArray::class) { +internal class FinalStaticFieldArrayTest : UtTestCaseChecker(testClass = FinalStaticFieldArray::class) { @Test fun testFactorial() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/IntArrayBasicsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/IntArrayBasicsTest.kt index 5d32297515..3a0eac72af 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/IntArrayBasicsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/IntArrayBasicsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.arrays -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.ge import org.utbot.examples.ignoreExecutionsNumber @@ -10,7 +10,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class IntArrayBasicsTest : AbstractTestCaseGeneratorTest( +internal class IntArrayBasicsTest : UtTestCaseChecker( testClass = IntArrayBasics::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/PrimitiveArraysTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/PrimitiveArraysTest.kt index afee906efa..3667895da4 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/PrimitiveArraysTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/arrays/PrimitiveArraysTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.arrays -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.eq import org.utbot.examples.isException @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class PrimitiveArraysTest : AbstractTestCaseGeneratorTest( +internal class PrimitiveArraysTest : UtTestCaseChecker( testClass = PrimitiveArrays::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/ArrayCastExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/ArrayCastExampleTest.kt index dfacfbea4b..9311b0aa26 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/ArrayCastExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/ArrayCastExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.casts -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test // TODO failed Kotlin compilation (generics) SAT-1332 //TODO: SAT-1487 calculate coverage for all methods of this test class -internal class ArrayCastExampleTest : AbstractTestCaseGeneratorTest( +internal class ArrayCastExampleTest : UtTestCaseChecker( testClass = ArrayCastExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/CastExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/CastExampleTest.kt index 277d88e8bf..5c34c3eaab 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/CastExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/CastExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.casts -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class CastExampleTest : AbstractTestCaseGeneratorTest( +internal class CastExampleTest : UtTestCaseChecker( testClass = CastExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/GenericCastExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/GenericCastExampleTest.kt index 20311105d4..c6754547d7 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/GenericCastExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/GenericCastExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.casts -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class GenericCastExampleTest : AbstractTestCaseGeneratorTest( +internal class GenericCastExampleTest : UtTestCaseChecker( testClass = GenericCastExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/InstanceOfExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/InstanceOfExampleTest.kt index 0972bdabb1..4fd4a1e53a 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/casts/InstanceOfExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/casts/InstanceOfExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.casts -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.ge @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class InstanceOfExampleTest : AbstractTestCaseGeneratorTest( +internal class InstanceOfExampleTest : UtTestCaseChecker( testClass = InstanceOfExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/ClassWithStaticAndInnerClassesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/ClassWithStaticAndInnerClassesTest.kt index 3cc02c8e18..05bee3864b 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/ClassWithStaticAndInnerClassesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/ClassWithStaticAndInnerClassesTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.codegen -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test @Suppress("INACCESSIBLE_TYPE") -internal class ClassWithStaticAndInnerClassesTest : AbstractTestCaseGeneratorTest(testClass = ClassWithStaticAndInnerClasses::class) { +internal class ClassWithStaticAndInnerClassesTest : UtTestCaseChecker(testClass = ClassWithStaticAndInnerClasses::class) { @Test fun testUsePrivateStaticClassWithPrivateField() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/CodegenExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/CodegenExampleTest.kt index cb15ba4995..edc9135ade 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/CodegenExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/CodegenExampleTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.codegen -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.mock.MockRandomExamples import org.utbot.examples.withoutConcrete import kotlin.reflect.full.functions import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class CodegenExampleTest : AbstractTestCaseGeneratorTest(testClass = CodegenExample::class) { +internal class CodegenExampleTest : UtTestCaseChecker(testClass = CodegenExample::class) { @Test fun firstExampleTest() { withoutConcrete { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/VoidStaticMethodsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/VoidStaticMethodsTest.kt index 1dfe2526f3..dadafac695 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/VoidStaticMethodsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/VoidStaticMethodsTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.codegen -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test -class VoidStaticMethodsTest : AbstractTestCaseGeneratorTest(testClass = VoidStaticMethodsTestingClass::class) { +class VoidStaticMethodsTest : UtTestCaseChecker(testClass = VoidStaticMethodsTestingClass::class) { @Test fun testInvokeChangeStaticFieldMethod() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/deepequals/DeepEqualsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/deepequals/DeepEqualsTest.kt index e98dbc640b..02dfcb65f7 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/deepequals/DeepEqualsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/codegen/deepequals/DeepEqualsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.codegen.deepequals -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO failed Kotlin compilation (generics) SAT-1332 -class DeepEqualsTest : AbstractTestCaseGeneratorTest( +class DeepEqualsTest : UtTestCaseChecker( testClass = DeepEqualsTestingClass::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/CustomerExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/CustomerExamplesTest.kt index 421268728e..9360695b3b 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/CustomerExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/CustomerExamplesTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.ignoreExecutionsNumber @@ -10,7 +10,7 @@ import org.utbot.framework.plugin.api.FieldId import org.utbot.framework.plugin.api.UtConcreteValue import org.junit.jupiter.api.Test -internal class CustomerExamplesTest: AbstractTestCaseGeneratorTest( +internal class CustomerExamplesTest: UtTestCaseChecker( testClass = CustomerExamples::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/GenericListsExample.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/GenericListsExample.kt index 755bdd27db..6dabf8186e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/GenericListsExample.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/GenericListsExample.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO disabled tests should be fixes with SAT-1441 -internal class GenericListsExampleTest : AbstractTestCaseGeneratorTest( +internal class GenericListsExampleTest : UtTestCaseChecker( testClass = GenericListsExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/LinkedListsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/LinkedListsTest.kt index fab796ada3..5e24a0f357 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/LinkedListsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/LinkedListsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation (generics) SAT-1332 -internal class LinkedListsTest : AbstractTestCaseGeneratorTest( +internal class LinkedListsTest : UtTestCaseChecker( testClass = LinkedLists::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListAlgorithmsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListAlgorithmsTest.kt index 445fbf914a..33f5023294 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListAlgorithmsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListAlgorithmsTest.kt @@ -1,7 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest -import org.utbot.examples.DoNotCalculate +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage @@ -9,7 +8,7 @@ import org.junit.jupiter.api.Test import org.utbot.examples.atLeast // TODO failed Kotlin compilation SAT-1332 -class ListAlgorithmsTest : AbstractTestCaseGeneratorTest( +class ListAlgorithmsTest : UtTestCaseChecker( testClass = ListAlgorithms::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListIteratorsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListIteratorsTest.kt index 5e320c5fda..a5cf3a9349 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListIteratorsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListIteratorsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.ignoreExecutionsNumber @@ -10,7 +10,7 @@ import kotlin.math.min import org.junit.jupiter.api.Test // TODO failed Kotlin compilation (generics) SAT-1332 -internal class ListIteratorsTest : AbstractTestCaseGeneratorTest( +internal class ListIteratorsTest : UtTestCaseChecker( testClass = ListIterators::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListWrapperReturnsVoidTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListWrapperReturnsVoidTest.kt index ebbb7a8c18..3eb2f75534 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListWrapperReturnsVoidTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListWrapperReturnsVoidTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation ($ in function names, generics) SAT-1220 SAT-1332 -internal class ListWrapperReturnsVoidTest : AbstractTestCaseGeneratorTest( +internal class ListWrapperReturnsVoidTest : UtTestCaseChecker( testClass = ListWrapperReturnsVoidExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListsTest.kt index feb5b8cdc4..3665156682 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.ge @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class ListsTest : AbstractTestCaseGeneratorTest( +internal class ListsTest : UtTestCaseChecker( testClass = Lists::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapEntrySetTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapEntrySetTest.kt index 30e50444ec..d873ec264e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapEntrySetTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapEntrySetTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq @@ -13,7 +13,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -class MapEntrySetTest : AbstractTestCaseGeneratorTest( +class MapEntrySetTest : UtTestCaseChecker( testClass = MapEntrySet::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapKeySetTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapKeySetTest.kt index 48172ee2d0..5c031c2007 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapKeySetTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapKeySetTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.AtLeast import org.utbot.examples.DoNotCalculate import org.utbot.examples.between @@ -15,7 +15,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -class MapKeySetTest : AbstractTestCaseGeneratorTest( +class MapKeySetTest : UtTestCaseChecker( testClass = MapKeySet::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapValuesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapValuesTest.kt index 45a78bea1c..962ab9dbeb 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapValuesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapValuesTest.kt @@ -1,10 +1,9 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.AtLeast import org.utbot.examples.DoNotCalculate import org.utbot.examples.between -import org.utbot.examples.eq import org.utbot.examples.ge import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.isException @@ -14,7 +13,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -class MapValuesTest : AbstractTestCaseGeneratorTest( +class MapValuesTest : UtTestCaseChecker( testClass = MapValues::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapsTest.kt index a66a07f044..f350b64c1d 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/MapsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.AtLeast import org.utbot.examples.DoNotCalculate import org.utbot.examples.between @@ -16,7 +16,7 @@ import org.utbot.framework.plugin.api.MockStrategyApi import org.junit.jupiter.api.Test // TODO failed Kotlin compilation ($ in names, generics) SAT-1220 SAT-1332 -internal class MapsTest : AbstractTestCaseGeneratorTest( +internal class MapsTest : UtTestCaseChecker( testClass = Maps::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/OptionalsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/OptionalsTest.kt index 0203e3ef6a..c32699845c 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/OptionalsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/OptionalsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq @@ -11,7 +11,7 @@ import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test -class OptionalsTest : AbstractTestCaseGeneratorTest( +class OptionalsTest : UtTestCaseChecker( Optionals::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetIteratorsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetIteratorsTest.kt index 89f05bb409..cf9f630bde 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetIteratorsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetIteratorsTest.kt @@ -1,7 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest -import org.utbot.examples.DoNotCalculate +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.between import org.utbot.examples.ge import org.utbot.examples.ignoreExecutionsNumber @@ -11,7 +10,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -class SetIteratorsTest : AbstractTestCaseGeneratorTest( +class SetIteratorsTest : UtTestCaseChecker( testClass = SetIterators::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetsTest.kt index 4ac6861aef..2a5c136910 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/collections/SetsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.collections -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.AtLeast import org.utbot.examples.DoNotCalculate import org.utbot.examples.between @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class SetsTest : AbstractTestCaseGeneratorTest( +internal class SetsTest : UtTestCaseChecker( testClass = Sets::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/ConditionsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/ConditionsTest.kt index b9a01de495..7047a40bca 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/ConditionsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/ConditionsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.controlflow -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.keyContain @@ -11,7 +11,7 @@ import org.utbot.framework.plugin.api.DocRegularStmt import org.utbot.framework.plugin.api.DocStatement import org.junit.jupiter.api.Test -internal class ConditionsTest : AbstractTestCaseGeneratorTest(testClass = Conditions::class) { +internal class ConditionsTest : UtTestCaseChecker(testClass = Conditions::class) { @Test fun testSimpleCondition() { val conditionSummary = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CycleDependedConditionTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CycleDependedConditionTest.kt index 3bb944b466..14cb835502 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CycleDependedConditionTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CycleDependedConditionTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.controlflow -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.keyContain import org.utbot.examples.keyMatch @@ -10,7 +10,7 @@ import org.utbot.framework.plugin.api.DocRegularStmt import org.utbot.framework.plugin.api.DocStatement import org.junit.jupiter.api.Test -internal class CycleDependedConditionTest : AbstractTestCaseGeneratorTest(testClass = CycleDependedCondition::class) { +internal class CycleDependedConditionTest : UtTestCaseChecker(testClass = CycleDependedCondition::class) { @Test fun testCycleDependedOneCondition() { val conditionSummary = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CyclesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CyclesTest.kt index b49cde4e76..d60070efc1 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CyclesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/CyclesTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.controlflow -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.between import org.utbot.examples.eq @@ -14,7 +14,7 @@ import org.utbot.framework.plugin.api.DocRegularStmt import org.utbot.framework.plugin.api.DocStatement import org.junit.jupiter.api.Test -internal class CyclesTest : AbstractTestCaseGeneratorTest(testClass = Cycles::class) { +internal class CyclesTest : UtTestCaseChecker(testClass = Cycles::class) { @Test fun testForCycle() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/SwitchTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/SwitchTest.kt index ede219ef32..3aca82a55f 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/SwitchTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/controlflow/SwitchTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.controlflow -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.ge import org.utbot.examples.keyContain @@ -17,7 +17,7 @@ import java.math.RoundingMode.HALF_EVEN import java.math.RoundingMode.HALF_UP import org.junit.jupiter.api.Test -internal class SwitchTest : AbstractTestCaseGeneratorTest(testClass = Switch::class) { +internal class SwitchTest : UtTestCaseChecker(testClass = Switch::class) { @Test fun testSimpleSwitch() { val switchCaseSummary = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/enums/ClassWithEnumTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/enums/ClassWithEnumTest.kt index 079bf1d01c..c726b3b2c6 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/enums/ClassWithEnumTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/enums/ClassWithEnumTest.kt @@ -1,7 +1,7 @@ package org.utbot.examples.enums import org.utbot.common.findField -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.enums.ClassWithEnum.StatusEnum.ERROR import org.utbot.examples.enums.ClassWithEnum.StatusEnum.READY @@ -14,7 +14,7 @@ import org.utbot.framework.plugin.api.util.id import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -class ClassWithEnumTest : AbstractTestCaseGeneratorTest(testClass = ClassWithEnum::class) { +class ClassWithEnumTest : UtTestCaseChecker(testClass = ClassWithEnum::class) { @Test fun testOrdinal() { withoutConcrete { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionClusteringExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionClusteringChecker.kt similarity index 93% rename from utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionClusteringExamplesTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionClusteringChecker.kt index 36bbe81361..0c3307fcd3 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionClusteringExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionClusteringChecker.kt @@ -1,6 +1,6 @@ package org.utbot.examples.exceptions -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.ge import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.primitiveValue @@ -11,8 +11,8 @@ import org.utbot.framework.plugin.api.UtModel import org.utbot.framework.plugin.api.UtTimeoutException import org.junit.jupiter.api.Test -internal class ExceptionClusteringExamplesTest : - AbstractModelBasedTest(testClass = ExceptionClusteringExamples::class) { +internal class ExceptionClusteringChecker : + UtModelChecker(testClass = ExceptionClusteringExamples::class) { /** * Difference is in throwing unchecked exceptions - for method under test is [UtExpectedCheckedThrow]. */ diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt index ad43e4c0bb..78d9498c01 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.exceptions -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.eq import org.utbot.examples.ignoreExecutionsNumber @@ -9,7 +9,7 @@ import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test -internal class ExceptionExamplesTest : AbstractTestCaseGeneratorTest( +internal class ExceptionExamplesTest : UtTestCaseChecker( testClass = ExceptionExamples::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/JvmCrashExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/JvmCrashExamplesTest.kt index adee01ba08..49fd9e1cec 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/JvmCrashExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/JvmCrashExamplesTest.kt @@ -1,15 +1,12 @@ package org.utbot.examples.exceptions -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq -import org.utbot.examples.ignoreExecutionsNumber -import org.utbot.examples.primitiveValue -import org.utbot.framework.plugin.api.UtModel import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class JvmCrashExamplesTest : AbstractTestCaseGeneratorTest(testClass = JvmCrashExamples::class) { +internal class JvmCrashExamplesTest : UtTestCaseChecker(testClass = JvmCrashExamples::class) { @Test @Disabled("JIRA:1527") fun testExit() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/InvokeExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/InvokeExampleTest.kt index 1fdf6aab18..361b5315fa 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/InvokeExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/InvokeExampleTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.invokes -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.isException import org.junit.jupiter.api.Test -internal class InvokeExampleTest : AbstractTestCaseGeneratorTest(testClass = InvokeExample::class) { +internal class InvokeExampleTest : UtTestCaseChecker(testClass = InvokeExample::class) { @Test fun testSimpleFormula() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/NativeExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/NativeExampleTest.kt index 4ce3b78c28..2dfa22ec82 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/NativeExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/NativeExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.invokes -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.eq import org.utbot.examples.ge @@ -10,7 +10,7 @@ import kotlin.math.sqrt import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test -internal class NativeExampleTest : AbstractTestCaseGeneratorTest(testClass = NativeExample::class) { +internal class NativeExampleTest : UtTestCaseChecker(testClass = NativeExample::class) { @Test fun testPartialEx() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/SimpleInterfaceExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/SimpleInterfaceExampleTest.kt index 5394703eaa..70c4b7e1ab 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/SimpleInterfaceExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/SimpleInterfaceExampleTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.invokes -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class SimpleInterfaceExampleTest : AbstractTestCaseGeneratorTest( +internal class SimpleInterfaceExampleTest : UtTestCaseChecker( testClass = SimpleInterfaceExample::class ) { @Test diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/StaticInvokeExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/StaticInvokeExampleTest.kt index c72af5b6b4..e32277b882 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/StaticInvokeExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/StaticInvokeExampleTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.invokes -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.between import kotlin.math.max import org.junit.jupiter.api.Test -internal class StaticInvokeExampleTest : AbstractTestCaseGeneratorTest(testClass = StaticInvokeExample::class) { +internal class StaticInvokeExampleTest : UtTestCaseChecker(testClass = StaticInvokeExample::class) { // TODO: inline local variables when types inference bug in Kotlin fixed @Test fun testMaxForThree() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/VirtualInvokeExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/VirtualInvokeExampleTest.kt index 7acbb9f503..97a254b875 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/VirtualInvokeExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/invokes/VirtualInvokeExampleTest.kt @@ -2,15 +2,14 @@ package org.utbot.examples.invokes -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException import java.lang.Boolean -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class VirtualInvokeExampleTest : AbstractTestCaseGeneratorTest(testClass = VirtualInvokeExample::class) { +internal class VirtualInvokeExampleTest : UtTestCaseChecker(testClass = VirtualInvokeExample::class) { @Test fun testSimpleVirtualInvoke() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/lambda/SimpleLambdaExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/lambda/SimpleLambdaExamplesTest.kt index ecd4a8976e..7fb61eca70 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/lambda/SimpleLambdaExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/lambda/SimpleLambdaExamplesTest.kt @@ -2,11 +2,11 @@ package org.utbot.examples.lambda import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.isException -class SimpleLambdaExamplesTest : AbstractTestCaseGeneratorTest(testClass = SimpleLambdaExamples::class) { +class SimpleLambdaExamplesTest : UtTestCaseChecker(testClass = SimpleLambdaExamples::class) { @Test fun testBiFunctionLambdaExample() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/make/symbolic/ClassWithComplicatedMethodsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/make/symbolic/ClassWithComplicatedMethodsTest.kt index b7279478c8..a1775dff49 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/make/symbolic/ClassWithComplicatedMethodsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/make/symbolic/ClassWithComplicatedMethodsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.make.symbolic -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.withoutConcrete @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test // This class is substituted with ComplicatedMethodsSubstitutionsStorage // but we cannot do in code generation. // For this reason code generation executions are disabled -internal class ClassWithComplicatedMethodsTest : AbstractTestCaseGeneratorTest( +internal class ClassWithComplicatedMethodsTest : UtTestCaseChecker( testClass = ClassWithComplicatedMethods::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/math/BitOperatorsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/math/BitOperatorsTest.kt index 0f21c4e0b3..5b4b8589b8 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/math/BitOperatorsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/math/BitOperatorsTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.math -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class BitOperatorsTest : AbstractTestCaseGeneratorTest(testClass = BitOperators::class) { +internal class BitOperatorsTest : UtTestCaseChecker(testClass = BitOperators::class) { @Test fun testComplement() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/math/DivRemExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/math/DivRemExamplesTest.kt index 2f2d936fe7..f7896a4f83 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/math/DivRemExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/math/DivRemExamplesTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.math -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.isException import org.junit.jupiter.api.Test -internal class DivRemExamplesTest : AbstractTestCaseGeneratorTest(testClass = DivRemExamples::class) { +internal class DivRemExamplesTest : UtTestCaseChecker(testClass = DivRemExamples::class) { @Test fun testDiv() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/math/DoubleFunctionsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/math/DoubleFunctionsTest.kt index c54d15346d..fe8d70e100 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/math/DoubleFunctionsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/math/DoubleFunctionsTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.math -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test @Suppress("SimplifyNegatedBinaryExpression") -internal class DoubleFunctionsTest : AbstractTestCaseGeneratorTest(testClass = DoubleFunctions::class) { +internal class DoubleFunctionsTest : UtTestCaseChecker(testClass = DoubleFunctions::class) { @Test @Tag("slow") fun testHypo() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/math/OverflowAsErrorTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/math/OverflowAsErrorTest.kt index bd389a2210..f8fb4a2796 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/math/OverflowAsErrorTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/math/OverflowAsErrorTest.kt @@ -2,7 +2,7 @@ package org.utbot.examples.math import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.AtLeast import org.utbot.examples.algorithms.Sort import org.utbot.examples.eq @@ -15,7 +15,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import kotlin.math.floor import kotlin.math.sqrt -internal class OverflowAsErrorTest : AbstractTestCaseGeneratorTest( +internal class OverflowAsErrorTest : UtTestCaseChecker( testClass = OverflowExamples::class, testCodeGeneration = true, // Don't launch tests, because ArithmeticException will be expected, but it is not supposed to be actually thrown. diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/LoggerExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/LoggerExampleTest.kt index 7d23115a66..df8fad27bd 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/LoggerExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/LoggerExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration @@ -12,7 +12,7 @@ import org.utbot.framework.plugin.api.UtStaticMethodInstrumentation import org.utbot.framework.plugin.api.isNull import org.junit.jupiter.api.Test -internal class LoggerExampleTest : AbstractTestCaseGeneratorTest( +internal class LoggerExampleTest : UtTestCaseChecker( testClass = LoggerExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/MonitorUsageTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/MonitorUsageTest.kt index 16a9b88d24..d237827850 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/MonitorUsageTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/MonitorUsageTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.ignoreExecutionsNumber import org.junit.jupiter.api.Test -internal class MonitorUsageTest : AbstractTestCaseGeneratorTest(testClass = MonitorUsage::class) { +internal class MonitorUsageTest : UtTestCaseChecker(testClass = MonitorUsage::class) { @Test fun testSimpleMonitor() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/OverloadTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/OverloadTest.kt index b8417f4ae3..726af5094d 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/OverloadTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/OverloadTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class OverloadTest : AbstractTestCaseGeneratorTest(testClass = Overload::class) { +internal class OverloadTest : UtTestCaseChecker(testClass = Overload::class) { @Test fun testSignOneParam() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/PrivateConstructorExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/PrivateConstructorExampleTest.kt index 934f605280..ac4195775c 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/PrivateConstructorExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/PrivateConstructorExampleTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class PrivateConstructorExampleTest : AbstractTestCaseGeneratorTest(testClass = PrivateConstructorExample::class) { +internal class PrivateConstructorExampleTest : UtTestCaseChecker(testClass = PrivateConstructorExample::class) { /** * Two branches need to be covered: diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimpleNoConditionTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimpleNoConditionTest.kt index bac0b0f1fc..cc8eceda00 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimpleNoConditionTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimpleNoConditionTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class SimpleNoConditionTest : AbstractTestCaseGeneratorTest(testClass = SimpleNoCondition::class) { +internal class SimpleNoConditionTest : UtTestCaseChecker(testClass = SimpleNoCondition::class) { @Test fun testNoConditionAdd() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimplifierTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimplifierTest.kt index f5143d743d..2287629917 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimplifierTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/SimplifierTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class SimplifierTest: AbstractTestCaseGeneratorTest(testClass = Simplifier::class) { +internal class SimplifierTest: UtTestCaseChecker(testClass = Simplifier::class) { @Test fun testSimplifyAdditionWithZero() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticInitializerExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticInitializerExampleTest.kt index 59e552f95e..b31dc426c9 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticInitializerExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticInitializerExampleTest.kt @@ -2,12 +2,12 @@ package org.utbot.examples.mixed import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.StaticInitializerExample import org.utbot.examples.eq @Disabled("Unknown build failure") -internal class StaticInitializerExampleTest : AbstractTestCaseGeneratorTest(testClass = StaticInitializerExample::class) { +internal class StaticInitializerExampleTest : UtTestCaseChecker(testClass = StaticInitializerExample::class) { @Test fun testPositive() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticMethodExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticMethodExamplesTest.kt index 4c7020fbc0..01238840e7 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticMethodExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mixed/StaticMethodExamplesTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.mixed -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class StaticMethodExamplesTest : AbstractTestCaseGeneratorTest(testClass = StaticMethodExamples::class) { +internal class StaticMethodExamplesTest : UtTestCaseChecker(testClass = StaticMethodExamples::class) { // TODO: inline local variables when types inference bug in Kotlin fixed @Test fun testComplement() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/ArgumentsMockTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/ArgumentsMockTest.kt index 0f8ddcbce9..2032d6205c 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/ArgumentsMockTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/ArgumentsMockTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq @@ -13,7 +13,7 @@ import org.utbot.examples.value import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES import org.junit.jupiter.api.Test -internal class ArgumentsMockTest : AbstractTestCaseGeneratorTest(testClass = ServiceWithArguments::class) { +internal class ArgumentsMockTest : UtTestCaseChecker(testClass = ServiceWithArguments::class) { @Test fun testMockForArguments_callMultipleMethods() { checkMocksAndInstrumentation( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/CommonMocksExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/CommonMocksExampleTest.kt index b51015d797..d47b5c18a8 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/CommonMocksExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/CommonMocksExampleTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.plugin.api.MockStrategyApi import org.junit.jupiter.api.Test -internal class CommonMocksExampleTest: AbstractTestCaseGeneratorTest(testClass = CommonMocksExample::class) { +internal class CommonMocksExampleTest: UtTestCaseChecker(testClass = CommonMocksExample::class) { @Test fun testMockInterfaceWithoutImplementors() { checkMocks( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/FieldMockTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/FieldMockTest.kt index 3e48b8c7ba..69e324da6e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/FieldMockTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/FieldMockTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq @@ -12,7 +12,7 @@ import org.utbot.examples.value import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES import org.junit.jupiter.api.Test -internal class FieldMockTest : AbstractTestCaseGeneratorTest(testClass = ServiceWithField::class) { +internal class FieldMockTest : UtTestCaseChecker(testClass = ServiceWithField::class) { @Test fun testMockForField_callMultipleMethods() { checkMocksAndInstrumentation( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/InnerMockWithFieldExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/InnerMockWithFieldChecker.kt similarity index 92% rename from utbot-framework/src/test/kotlin/org/utbot/examples/mock/InnerMockWithFieldExampleTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/mock/InnerMockWithFieldChecker.kt index 3e02c56651..b0cfd22752 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/InnerMockWithFieldExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/InnerMockWithFieldChecker.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.eq import org.utbot.examples.primitiveValue import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES @@ -11,7 +11,7 @@ import org.utbot.framework.plugin.api.isNotNull import org.utbot.framework.plugin.api.isNull import org.junit.jupiter.api.Test -internal class InnerMockWithFieldExampleTest : AbstractModelBasedTest(testClass = InnerMockWithFieldExample::class) { +internal class InnerMockWithFieldChecker : UtModelChecker(testClass = InnerMockWithFieldExample::class) { @Test fun testCheckAndUpdate() { checkStatic( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockFinalClassTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockFinalClassTest.kt index c0f3286a1b..8aa6e687d0 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockFinalClassTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockFinalClassTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.ge import org.utbot.examples.mock.others.FinalClass @@ -9,7 +9,7 @@ import org.utbot.examples.value import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_CLASSES import org.junit.jupiter.api.Test -internal class MockFinalClassTest : AbstractTestCaseGeneratorTest(testClass = MockReturnObjectExample::class) { +internal class MockFinalClassTest : UtTestCaseChecker(testClass = MockReturnObjectExample::class) { @Test fun testFinalClass() { checkMocks( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockRandomTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockRandomTest.kt index eb94eb94b4..478f309508 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockRandomTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockRandomTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isParameter @@ -13,7 +13,7 @@ import org.utbot.framework.plugin.api.UtNewInstanceInstrumentation import java.util.Random import org.junit.jupiter.api.Test -internal class MockRandomTest : AbstractTestCaseGeneratorTest(testClass = MockRandomExamples::class) { +internal class MockRandomTest : UtTestCaseChecker(testClass = MockRandomExamples::class) { @Test fun testRandomAsParameter() { val method: Random.() -> Int = Random::nextInt diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockReturnObjectExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockReturnObjectExampleTest.kt index b3c787e5da..4f41752332 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockReturnObjectExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockReturnObjectExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.mock.others.Generator @@ -12,7 +12,7 @@ import org.utbot.examples.value import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES import org.junit.jupiter.api.Test -internal class MockReturnObjectExampleTest : AbstractTestCaseGeneratorTest(testClass = MockReturnObjectExample::class) { +internal class MockReturnObjectExampleTest : UtTestCaseChecker(testClass = MockReturnObjectExample::class) { @Test fun testMockReturnObject() { checkMocks( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticFieldExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticFieldExampleTest.kt index 9467f7da0b..027927544b 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticFieldExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticFieldExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.mock.others.Generator @@ -14,7 +14,7 @@ import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES import kotlin.reflect.KClass import org.junit.jupiter.api.Test -internal class MockStaticFieldExampleTest : AbstractTestCaseGeneratorTest(testClass = MockStaticFieldExample::class) { +internal class MockStaticFieldExampleTest : UtTestCaseChecker(testClass = MockStaticFieldExample::class) { @Test fun testMockStaticField() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticMethodExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticMethodExampleTest.kt index 203c5bd5cb..bb385facdc 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticMethodExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockStaticMethodExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.plugin.api.MockStrategyApi @@ -10,7 +10,7 @@ import org.utbot.framework.util.singleStaticMethod import org.utbot.framework.util.singleValue import org.junit.jupiter.api.Test -internal class MockStaticMethodExampleTest : AbstractTestCaseGeneratorTest(testClass = MockStaticMethodExample::class) { +internal class MockStaticMethodExampleTest : UtTestCaseChecker(testClass = MockStaticMethodExample::class) { @Test fun testUseStaticMethod() { checkMocksAndInstrumentation( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithFieldExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithFieldChecker.kt similarity index 91% rename from utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithFieldExampleTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithFieldChecker.kt index 6c0fd02030..a7de107d21 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithFieldExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithFieldChecker.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.eq import org.utbot.examples.primitiveValue import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES @@ -10,7 +10,7 @@ import org.utbot.framework.plugin.api.isMockModel import org.utbot.framework.plugin.api.isNull import org.junit.jupiter.api.Test -internal class MockWithFieldExampleTest : AbstractModelBasedTest(testClass = MockWithFieldExample::class) { +internal class MockWithFieldChecker : UtModelChecker(testClass = MockWithFieldExample::class) { @Test fun testCheckAndUpdate() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithSideEffectExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithSideEffectExampleTest.kt index a8aeb24a9c..169cebde32 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithSideEffectExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockWithSideEffectExampleTest.kt @@ -1,14 +1,13 @@ package org.utbot.examples.mock -import org.junit.Ignore -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException import org.utbot.framework.plugin.api.MockStrategyApi import org.junit.Test -internal class MockWithSideEffectExampleTest : AbstractTestCaseGeneratorTest(testClass = MockWithSideEffectExample::class) { +internal class MockWithSideEffectExampleTest : UtTestCaseChecker(testClass = MockWithSideEffectExample::class) { @Test fun testSideEffect() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/StaticFieldMockTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/StaticFieldMockTest.kt index 5bae958d0a..3dc17f0588 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/StaticFieldMockTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/StaticFieldMockTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.mock.provider.Provider @@ -11,7 +11,7 @@ import org.utbot.examples.value import org.utbot.framework.plugin.api.MockStrategyApi.OTHER_PACKAGES import org.junit.jupiter.api.Test -internal class StaticFieldMockTest : AbstractTestCaseGeneratorTest(testClass = ServiceWithStaticField::class) { +internal class StaticFieldMockTest : UtTestCaseChecker(testClass = ServiceWithStaticField::class) { @Test fun testMockForStaticField_callMultipleMethods() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/UseNetworkTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/UseNetworkTest.kt index 85e4de9806..60fb7d2c57 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/UseNetworkTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/UseNetworkTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException @@ -8,7 +8,7 @@ import org.utbot.framework.plugin.api.MockStrategyApi import org.utbot.framework.plugin.api.UtConcreteValue import org.junit.jupiter.api.Test -internal class UseNetworkTest : AbstractTestCaseGeneratorTest(testClass = UseNetwork::class) { +internal class UseNetworkTest : UtTestCaseChecker(testClass = UseNetwork::class) { @Test fun testReadBytes() { val method = UseNetwork::readBytes diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/aliasing/AliasingInParamsExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/aliasing/AliasingInParamsExampleTest.kt index c6a214d8b6..aab4e7f3ac 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/aliasing/AliasingInParamsExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/aliasing/AliasingInParamsExampleTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.mock.aliasing -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.plugin.api.MockStrategyApi import org.junit.jupiter.api.Test -internal class AliasingInParamsExampleTest : AbstractTestCaseGeneratorTest(testClass = AliasingInParamsExample::class) { +internal class AliasingInParamsExampleTest : UtTestCaseChecker(testClass = AliasingInParamsExample::class) { @Test fun testExamplePackageBased() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/FieldMockModelBasedTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/FieldMockChecker.kt similarity index 90% rename from utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/FieldMockModelBasedTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/FieldMockChecker.kt index 8e798f823e..44d6303c4e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/FieldMockModelBasedTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/FieldMockChecker.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock.model -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.eq import org.utbot.examples.mock.provider.impl.ProviderImpl import org.utbot.examples.mock.service.impl.ServiceWithField @@ -11,7 +11,7 @@ import org.utbot.framework.plugin.api.isNotNull import org.utbot.framework.plugin.api.isNull import org.junit.jupiter.api.Test -internal class FieldMockModelBasedTest : AbstractModelBasedTest(testClass = ServiceWithField::class) { +internal class FieldMockChecker : UtModelChecker(testClass = ServiceWithField::class) { @Test fun testMockForField_IntPrimitive() { checkStatic( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/UseNetworkModelBasedTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/UseNetworkModelBasedTest.kt index f1fe9ff5e3..cb9d69b534 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/UseNetworkModelBasedTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/mock/model/UseNetworkModelBasedTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.mock.model -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.eq import org.utbot.examples.mock.UseNetwork import org.utbot.framework.plugin.api.MockStrategyApi @@ -8,7 +8,7 @@ import org.utbot.framework.plugin.api.UtCompositeModel import org.utbot.framework.plugin.api.UtVoidModel import org.junit.jupiter.api.Test -internal class UseNetworkModelBasedTest : AbstractModelBasedTest(testClass = UseNetwork::class) { +internal class UseNetworkModelBasedTest : UtModelChecker(testClass = UseNetwork::class) { @Test fun testMockVoidMethod() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/models/CompositeModelMinimizationExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/models/CompositeModelMinimizationChecker.kt similarity index 95% rename from utbot-framework/src/test/kotlin/org/utbot/examples/models/CompositeModelMinimizationExampleTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/models/CompositeModelMinimizationChecker.kt index 9d8123232b..f0a2bb3be8 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/models/CompositeModelMinimizationExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/models/CompositeModelMinimizationChecker.kt @@ -1,6 +1,6 @@ package org.utbot.examples.models -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage @@ -11,7 +11,7 @@ import org.utbot.framework.plugin.api.UtModel import org.utbot.framework.plugin.api.UtReferenceModel import org.junit.Test -internal class CompositeModelMinimizationExampleTest : AbstractModelBasedTest( +internal class CompositeModelMinimizationChecker : UtModelChecker( testClass = CompositeModelMinimizationExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/models/ModelsIdEqualityExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/models/ModelsIdEqualityChecker.kt similarity index 97% rename from utbot-framework/src/test/kotlin/org/utbot/examples/models/ModelsIdEqualityExampleTest.kt rename to utbot-framework/src/test/kotlin/org/utbot/examples/models/ModelsIdEqualityChecker.kt index e19dc189dd..9d479c43cf 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/models/ModelsIdEqualityExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/models/ModelsIdEqualityChecker.kt @@ -1,6 +1,6 @@ package org.utbot.examples.models -import org.utbot.examples.AbstractModelBasedTest +import org.utbot.examples.UtModelChecker import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage @@ -12,7 +12,7 @@ import org.utbot.framework.plugin.api.UtReferenceModel import org.junit.jupiter.api.Test // TODO failed Kotlin compilation SAT-1332 -internal class ModelsIdEqualityExampleTest : AbstractModelBasedTest( +internal class ModelsIdEqualityChecker : UtModelChecker( testClass = ModelsIdEqualityExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/natives/NativeExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/natives/NativeExamplesTest.kt index a99b6a41cc..8e03592ccb 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/natives/NativeExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/natives/NativeExamplesTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.natives -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.ge import org.junit.jupiter.api.Test import org.utbot.examples.withSolverTimeoutInMillis -internal class NativeExamplesTest : AbstractTestCaseGeneratorTest(testClass = NativeExamples::class) { +internal class NativeExamplesTest : UtTestCaseChecker(testClass = NativeExamples::class) { @Test fun testFindAndPrintSum() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/AnonymousClassesExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/AnonymousClassesExampleTest.kt index 2c078d0528..bd90ce4ca5 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/AnonymousClassesExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/AnonymousClassesExampleTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException import org.junit.jupiter.api.Test -class AnonymousClassesExampleTest : AbstractTestCaseGeneratorTest(testClass = AnonymousClassesExample::class) { +class AnonymousClassesExampleTest : UtTestCaseChecker(testClass = AnonymousClassesExample::class) { @Test fun testAnonymousClassAsParam() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassRefTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassRefTest.kt index 56988441cd..ca222f6ea3 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassRefTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassRefTest.kt @@ -2,7 +2,7 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration @@ -13,7 +13,7 @@ import kotlin.Suppress import kotlin.arrayOf import org.junit.jupiter.api.Test -internal class ClassRefTest : AbstractTestCaseGeneratorTest( +internal class ClassRefTest : UtTestCaseChecker( testClass = ClassRef::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassWithClassRefTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassWithClassRefTest.kt index d96311db6b..dda77477db 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassWithClassRefTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ClassWithClassRefTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.isException @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test // TODO Kotlin compilation SAT-1332 // Code generation executions fail due we cannot analyze strings properly for now -internal class ClassWithClassRefTest : AbstractTestCaseGeneratorTest( +internal class ClassWithClassRefTest : UtTestCaseChecker( testClass = ClassWithClassRef::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/HiddenFieldExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/HiddenFieldExampleTest.kt index d7466b7c2a..a3168044c4 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/HiddenFieldExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/HiddenFieldExampleTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class HiddenFieldExampleTest : AbstractTestCaseGeneratorTest(testClass = HiddenFieldExample::class) { +internal class HiddenFieldExampleTest : UtTestCaseChecker(testClass = HiddenFieldExample::class) { @Test // Engine creates HiddenFieldSuccClass instead of HiddenFieldSuperClass, feels wrong field and matchers fail fun testCheckHiddenField() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ModelMinimizationExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ModelMinimizationExamplesTest.kt index db84fb2da0..dbff807f9c 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ModelMinimizationExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ModelMinimizationExamplesTest.kt @@ -1,12 +1,11 @@ package org.utbot.examples.objects -import org.junit.Ignore -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.Test -internal class ModelMinimizationExamplesTest : AbstractTestCaseGeneratorTest(testClass = ModelMinimizationExamples::class) { +internal class ModelMinimizationExamplesTest : UtTestCaseChecker(testClass = ModelMinimizationExamples::class) { @Test fun singleValueComparisonTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithFinalStaticTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithFinalStaticTest.kt index ad1e5707c7..c168ca03a5 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithFinalStaticTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithFinalStaticTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.singleValue @@ -8,7 +8,7 @@ import org.utbot.framework.codegen.CodeGeneration import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test -class ObjectWithFinalStaticTest : AbstractTestCaseGeneratorTest( +class ObjectWithFinalStaticTest : UtTestCaseChecker( testClass = ObjectWithFinalStatic::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesClassTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesClassTest.kt index 4ddb71f2ef..b2de169afb 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesClassTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesClassTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import kotlin.reflect.KFunction0 import kotlin.reflect.KFunction3 import org.junit.jupiter.api.Test -internal class ObjectWithPrimitivesClassTest : AbstractTestCaseGeneratorTest(testClass = ObjectWithPrimitivesClass::class) { +internal class ObjectWithPrimitivesClassTest : UtTestCaseChecker(testClass = ObjectWithPrimitivesClass::class) { @Test fun testDefaultConstructor() { val method: KFunction0 = ::ObjectWithPrimitivesClass diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesExampleTest.kt index 93e083be24..24f3fd160b 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithPrimitivesExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.atLeast import org.utbot.examples.eq @@ -9,7 +9,7 @@ import org.utbot.examples.isException import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class ObjectWithPrimitivesExampleTest : AbstractTestCaseGeneratorTest(testClass = ObjectWithPrimitivesExample::class) { +internal class ObjectWithPrimitivesExampleTest : UtTestCaseChecker(testClass = ObjectWithPrimitivesExample::class) { @Test fun testMax() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithRefFieldsExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithRefFieldsExampleTest.kt index a3f6202095..a24e7b904e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithRefFieldsExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithRefFieldsExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.atLeast import org.utbot.examples.eq @@ -8,7 +8,7 @@ import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.isException import org.junit.jupiter.api.Test -internal class ObjectWithRefFieldsExampleTest : AbstractTestCaseGeneratorTest(testClass = ObjectWithRefFieldExample::class) { +internal class ObjectWithRefFieldsExampleTest : UtTestCaseChecker(testClass = ObjectWithRefFieldExample::class) { @Test fun testDefaultValue() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithStaticFieldsExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithStaticFieldsExampleTest.kt index cd4e2fba50..8f9f4802a0 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithStaticFieldsExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithStaticFieldsExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.findByName @@ -8,7 +8,7 @@ import org.utbot.examples.ignoreExecutionsNumber import org.utbot.examples.singleValue import org.junit.jupiter.api.Test -internal class ObjectWithStaticFieldsExampleTest : AbstractTestCaseGeneratorTest(testClass = ObjectWithStaticFieldsExample::class) { +internal class ObjectWithStaticFieldsExampleTest : UtTestCaseChecker(testClass = ObjectWithStaticFieldsExample::class) { @Test fun testReadFromStaticArray() { checkStatics( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithThrowableConstructorTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithThrowableConstructorTest.kt index 9c857fad6c..b3647ee6e0 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithThrowableConstructorTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/ObjectWithThrowableConstructorTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import kotlin.reflect.KFunction2 import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class ObjectWithThrowableConstructorTest : AbstractTestCaseGeneratorTest(testClass = ObjectWithThrowableConstructor::class) { +internal class ObjectWithThrowableConstructorTest : UtTestCaseChecker(testClass = ObjectWithThrowableConstructor::class) { @Test @Disabled("SAT-1500 Support verification of UtAssembleModel for possible exceptions") fun testThrowableConstructor() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/PrivateFieldsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/PrivateFieldsTest.kt index e8ad23c0d6..26f89b88b6 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/PrivateFieldsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/PrivateFieldsTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.isException import org.junit.jupiter.api.Test -internal class PrivateFieldsTest : AbstractTestCaseGeneratorTest(testClass = PrivateFields::class) { +internal class PrivateFieldsTest : UtTestCaseChecker(testClass = PrivateFields::class) { @Test fun testAccessWithGetter() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/RecursiveTypeTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/RecursiveTypeTest.kt index b821cf8de6..e1d9b137e0 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/RecursiveTypeTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/RecursiveTypeTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class RecursiveTypeTest : AbstractTestCaseGeneratorTest(testClass = RecursiveType::class) { +internal class RecursiveTypeTest : UtTestCaseChecker(testClass = RecursiveType::class) { @Test fun testNextValue() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassExampleTest.kt index 82840e022f..361052e3b6 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassExampleTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.objects -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq @@ -13,7 +13,7 @@ import org.utbot.framework.plugin.api.DocRegularStmt import org.utbot.framework.plugin.api.DocStatement import org.junit.jupiter.api.Test -internal class SimpleClassExampleTest : AbstractTestCaseGeneratorTest(testClass = SimpleClassExample::class) { +internal class SimpleClassExampleTest : UtTestCaseChecker(testClass = SimpleClassExample::class) { @Test fun simpleConditionTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassMultiInstanceExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassMultiInstanceExampleTest.kt index 7b552ada8b..d54bbd8156 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassMultiInstanceExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/objects/SimpleClassMultiInstanceExampleTest.kt @@ -1,12 +1,11 @@ package org.utbot.examples.objects -import org.junit.Ignore -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.Test -internal class SimpleClassMultiInstanceExampleTest : AbstractTestCaseGeneratorTest(testClass = SimpleClassMultiInstanceExample::class) { +internal class SimpleClassMultiInstanceExampleTest : UtTestCaseChecker(testClass = SimpleClassMultiInstanceExample::class) { @Test fun singleObjectChangeTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/ByteExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/ByteExamplesTest.kt index 968cf9d80c..24b4b9ef9b 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/ByteExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/ByteExamplesTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.primitives -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class ByteExamplesTest : AbstractTestCaseGeneratorTest(testClass = ByteExamples::class) { +internal class ByteExamplesTest : UtTestCaseChecker(testClass = ByteExamples::class) { @Test fun testNegByte() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/CharExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/CharExamplesTest.kt index b08a0d755a..22b6a29dc1 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/CharExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/CharExamplesTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.primitives -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.isException import org.junit.jupiter.api.Test -internal class CharExamplesTest : AbstractTestCaseGeneratorTest(testClass = CharExamples::class) { +internal class CharExamplesTest : UtTestCaseChecker(testClass = CharExamples::class) { @Test fun testCharDiv() { checkWithException( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/DoubleExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/DoubleExamplesTest.kt index 7897743404..680ff35c5a 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/DoubleExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/DoubleExamplesTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.primitives -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test @Suppress("SimplifyNegatedBinaryExpression") -internal class DoubleExamplesTest : AbstractTestCaseGeneratorTest(testClass = DoubleExamples::class) { +internal class DoubleExamplesTest : UtTestCaseChecker(testClass = DoubleExamples::class) { @Test fun testCompareSum() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/FloatExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/FloatExamplesTest.kt index d5c4fddc81..ceaf63cf62 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/FloatExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/FloatExamplesTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.primitives -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class FloatExamplesTest : AbstractTestCaseGeneratorTest(testClass = FloatExamples::class) { +internal class FloatExamplesTest : UtTestCaseChecker(testClass = FloatExamples::class) { @Test fun testFloatInfinity() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/IntExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/IntExamplesTest.kt index fea160c24f..b0dc0d889f 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/IntExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/primitives/IntExamplesTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.primitives -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @Suppress("ConvertTwoComparisonsToRangeCheck") -internal class IntExamplesTest : AbstractTestCaseGeneratorTest(testClass = IntExamples::class) { +internal class IntExamplesTest : UtTestCaseChecker(testClass = IntExamples::class) { @Test @Disabled("SAT-1009 [JAVA] Engine can't analyze isInteger") fun testIsInteger() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/recursion/RecursionTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/recursion/RecursionTest.kt index 6e6e6f20e6..2ccce3c7a4 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/recursion/RecursionTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/recursion/RecursionTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.recursion -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.between import org.utbot.examples.eq @@ -16,7 +16,7 @@ import kotlin.math.pow import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class RecursionTest : AbstractTestCaseGeneratorTest(testClass = Recursion::class) { +internal class RecursionTest : UtTestCaseChecker(testClass = Recursion::class) { @Test fun testFactorial() { val factorialSummary = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/statics/substitution/StaticsSubstitutionTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/statics/substitution/StaticsSubstitutionTest.kt index b453d95408..ffb4f2644e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/statics/substitution/StaticsSubstitutionTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/statics/substitution/StaticsSubstitutionTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.statics.substitution -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.withoutSubstituteStaticsWithSymbolicVariable import org.junit.jupiter.api.Test -class StaticsSubstitutionTest : AbstractTestCaseGeneratorTest(testClass = StaticSubstitutionExamples::class) { +class StaticsSubstitutionTest : UtTestCaseChecker(testClass = StaticSubstitutionExamples::class) { @Test fun lessThanZeroWithSubstitution() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/stdlib/DateExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/stdlib/DateExampleTest.kt index 3b72c0663c..f3fd68258d 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/stdlib/DateExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/stdlib/DateExampleTest.kt @@ -2,13 +2,13 @@ package org.utbot.examples.stdlib import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.utbot.examples.isException import org.utbot.examples.withUsingReflectionForMaximizingCoverage import java.util.Date -class DateExampleTest : AbstractTestCaseGeneratorTest(testClass = DateExample::class) { +class DateExampleTest : UtTestCaseChecker(testClass = DateExample::class) { @Suppress("SpellCheckingInspection") @Tag("slow") @Test diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt index 5ab5a133b9..2e4beeb126 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt @@ -3,7 +3,7 @@ package org.utbot.examples.stream import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.Full import org.utbot.examples.FullWithAssumptions @@ -20,7 +20,7 @@ import kotlin.streams.toList // TODO 1 instruction is always uncovered https://github.com/UnitTestBot/UTBotJava/issues/193 // TODO failed Kotlin compilation (generics) JIRA:1332 -class BaseStreamExampleTest : AbstractTestCaseGeneratorTest( +class BaseStreamExampleTest : UtTestCaseChecker( testClass = BaseStreamExample::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/strings/StringExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/strings/StringExamplesTest.kt index 196b63e19f..7a18fa913b 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/strings/StringExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/strings/StringExamplesTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.strings -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.atLeast import org.utbot.examples.between @@ -17,7 +17,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.utbot.examples.withSolverTimeoutInMillis -internal class StringExamplesTest : AbstractTestCaseGeneratorTest( +internal class StringExamplesTest : UtTestCaseChecker( testClass = StringExamples::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/structures/HeapTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/structures/HeapTest.kt index ff9cea7309..9e41230cdf 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/structures/HeapTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/structures/HeapTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.structures -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.ignoreExecutionsNumber import org.junit.jupiter.api.Test -internal class HeapTest : AbstractTestCaseGeneratorTest(testClass = Heap::class) { +internal class HeapTest : UtTestCaseChecker(testClass = Heap::class) { @Test fun testIsHeap() { val method = Heap::isHeap diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/structures/MinStackExampleTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/structures/MinStackExampleTest.kt index ea97e066cb..92c8788b28 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/structures/MinStackExampleTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/structures/MinStackExampleTest.kt @@ -1,13 +1,13 @@ package org.utbot.examples.structures -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.between import org.utbot.examples.eq import kotlin.math.min import org.junit.jupiter.api.Test -internal class MinStackExampleTest : AbstractTestCaseGeneratorTest(testClass = MinStackExample::class) { +internal class MinStackExampleTest : UtTestCaseChecker(testClass = MinStackExample::class) { @Test fun testCreate() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/structures/StandardStructuresTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/structures/StandardStructuresTest.kt index abe0ea16ae..fc957892e0 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/structures/StandardStructuresTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/structures/StandardStructuresTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.structures -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.keyContain @@ -14,7 +14,7 @@ import java.util.TreeMap import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class StandardStructuresTest : AbstractTestCaseGeneratorTest(testClass = StandardStructures::class) { +internal class StandardStructuresTest : UtTestCaseChecker(testClass = StandardStructures::class) { @Test @Disabled("TODO down cast for object wrapper JIRA:1480") fun testGetList() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/thirdparty/numbers/ArithmeticUtilsTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/thirdparty/numbers/ArithmeticUtilsTest.kt index a1aaf0af8d..c2b6e26393 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/thirdparty/numbers/ArithmeticUtilsTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/thirdparty/numbers/ArithmeticUtilsTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.thirdparty.numbers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test // example from Apache common-numbers -internal class ArithmeticUtilsTest : AbstractTestCaseGeneratorTest(testClass = ArithmeticUtils::class) { +internal class ArithmeticUtilsTest : UtTestCaseChecker(testClass = ArithmeticUtils::class) { @Test @Tag("slow") fun testPow() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/types/CastExamplesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/types/CastExamplesTest.kt index bd43ff4fa5..8d81703a92 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/types/CastExamplesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/types/CastExamplesTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.types -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test @Suppress("SimplifyNegatedBinaryExpression") -internal class CastExamplesTest : AbstractTestCaseGeneratorTest(testClass = CastExamples::class) { +internal class CastExamplesTest : UtTestCaseChecker(testClass = CastExamples::class) { @Test fun testLongToByte() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeBordersTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeBordersTest.kt index d5c8a149cf..dc90c85f77 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeBordersTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeBordersTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.types -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.atLeast import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class TypeBordersTest : AbstractTestCaseGeneratorTest(testClass = TypeBorders::class) { +internal class TypeBordersTest : UtTestCaseChecker(testClass = TypeBorders::class) { @Test fun testByteBorder() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeMatchesTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeMatchesTest.kt index 7d3293e8d5..7970849acc 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeMatchesTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/types/TypeMatchesTest.kt @@ -1,11 +1,11 @@ package org.utbot.examples.types -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test @Suppress("SimplifyNegatedBinaryExpression") -internal class TypeMatchesTest : AbstractTestCaseGeneratorTest(testClass = TypeMatches::class) { +internal class TypeMatchesTest : UtTestCaseChecker(testClass = TypeMatches::class) { @Test fun testCompareDoubleByte() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/unsafe/UnsafeWithFieldTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/unsafe/UnsafeWithFieldTest.kt index 1a42e853f7..fd478ac5e9 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/unsafe/UnsafeWithFieldTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/unsafe/UnsafeWithFieldTest.kt @@ -1,10 +1,10 @@ package org.utbot.examples.unsafe -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.eq import org.junit.jupiter.api.Test -internal class UnsafeWithFieldTest: AbstractTestCaseGeneratorTest(UnsafeWithField::class) { +internal class UnsafeWithFieldTest: UtTestCaseChecker(UnsafeWithField::class) { @Test fun checkSetField() { diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/BooleanWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/BooleanWrapperTest.kt index a9605860e3..d08c64bc00 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/BooleanWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/BooleanWrapperTest.kt @@ -1,12 +1,11 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class BooleanWrapperTest : AbstractTestCaseGeneratorTest(testClass = BooleanWrapper::class) { +internal class BooleanWrapperTest : UtTestCaseChecker(testClass = BooleanWrapper::class) { @Test fun primitiveToWrapperTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ByteWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ByteWrapperTest.kt index 1b36245469..f83b4900d9 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ByteWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ByteWrapperTest.kt @@ -1,12 +1,11 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class ByteWrapperTest : AbstractTestCaseGeneratorTest(testClass = ByteWrapper::class) { +internal class ByteWrapperTest : UtTestCaseChecker(testClass = ByteWrapper::class) { @Test fun primitiveToWrapperTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/CharacterWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/CharacterWrapperTest.kt index 786052acd2..1433dd8a69 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/CharacterWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/CharacterWrapperTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.framework.codegen.CodeGeneration @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test // TODO failed Kotlin compilation -internal class CharacterWrapperTest : AbstractTestCaseGeneratorTest( +internal class CharacterWrapperTest : UtTestCaseChecker( testClass = CharacterWrapper::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/DoubleWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/DoubleWrapperTest.kt index c42fe7bc9e..f8ce7e1d75 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/DoubleWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/DoubleWrapperTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test @Suppress("SimplifyNegatedBinaryExpression") -internal class DoubleWrapperTest : AbstractTestCaseGeneratorTest(testClass = DoubleWrapper::class) { +internal class DoubleWrapperTest : UtTestCaseChecker(testClass = DoubleWrapper::class) { @Test fun primitiveToWrapperTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/FloatWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/FloatWrapperTest.kt index ba73d3ad04..6d9feb6149 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/FloatWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/FloatWrapperTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Test @Suppress("SimplifyNegatedBinaryExpression") -internal class FloatWrapperTest : AbstractTestCaseGeneratorTest(testClass = FloatWrapper::class) { +internal class FloatWrapperTest : UtTestCaseChecker(testClass = FloatWrapper::class) { @Test fun primitiveToWrapperTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/IntegerWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/IntegerWrapperTest.kt index c7d684a078..ac5973261c 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/IntegerWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/IntegerWrapperTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class IntegerWrapperTest : AbstractTestCaseGeneratorTest(testClass = IntegerWrapper::class) { +internal class IntegerWrapperTest : UtTestCaseChecker(testClass = IntegerWrapper::class) { @Test fun primitiveToWrapperTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/LongWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/LongWrapperTest.kt index 269dabf5f7..57018e548e 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/LongWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/LongWrapperTest.kt @@ -1,6 +1,6 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.utbot.examples.withoutMinimization @@ -9,7 +9,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class LongWrapperTest : AbstractTestCaseGeneratorTest( +internal class LongWrapperTest : UtTestCaseChecker( testClass = LongWrapper::class, testCodeGeneration = true, languagePipelines = listOf( diff --git a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ShortWrapperTest.kt b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ShortWrapperTest.kt index 3631719ccc..6202d1e652 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ShortWrapperTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/examples/wrappers/ShortWrapperTest.kt @@ -1,12 +1,12 @@ package org.utbot.examples.wrappers -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.DoNotCalculate import org.utbot.examples.eq import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test -internal class ShortWrapperTest : AbstractTestCaseGeneratorTest(testClass = ShortWrapper::class) { +internal class ShortWrapperTest : UtTestCaseChecker(testClass = ShortWrapper::class) { @Test fun primitiveToWrapperTest() { check( diff --git a/utbot-framework/src/test/kotlin/org/utbot/framework/SootUtils.kt b/utbot-framework/src/test/kotlin/org/utbot/framework/SootUtils.kt index ced794ae2b..bfd9ea4750 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/framework/SootUtils.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/framework/SootUtils.kt @@ -1,7 +1,7 @@ package org.utbot.framework import org.utbot.common.FileUtil -import org.utbot.framework.plugin.api.runSoot +import org.utbot.framework.util.runSoot import java.nio.file.Path import kotlin.reflect.KClass diff --git a/utbot-framework/src/test/kotlin/org/utbot/framework/codegen/BaseTestCodeGeneratorPipeline.kt b/utbot-framework/src/test/kotlin/org/utbot/framework/codegen/TestCodeGeneratorPipeline.kt similarity index 93% rename from utbot-framework/src/test/kotlin/org/utbot/framework/codegen/BaseTestCodeGeneratorPipeline.kt rename to utbot-framework/src/test/kotlin/org/utbot/framework/codegen/TestCodeGeneratorPipeline.kt index cd715c73c8..7b46f4a2ea 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/framework/codegen/BaseTestCodeGeneratorPipeline.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/framework/codegen/TestCodeGeneratorPipeline.kt @@ -5,13 +5,12 @@ import org.utbot.common.bracket import org.utbot.common.info import org.utbot.common.packageName import org.utbot.examples.TestFrameworkConfiguration -import org.utbot.framework.codegen.ExecutionStatus.FAILED import org.utbot.framework.codegen.ExecutionStatus.SUCCESS -import org.utbot.framework.codegen.model.ModelBasedTestCodeGenerator +import org.utbot.framework.codegen.model.CodeGenerator import org.utbot.framework.plugin.api.CodegenLanguage import org.utbot.framework.plugin.api.MockFramework import org.utbot.framework.plugin.api.MockStrategyApi -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtMethod import org.utbot.framework.plugin.api.UtTestCase import org.utbot.framework.plugin.api.util.UtContext @@ -23,7 +22,7 @@ import org.junit.jupiter.api.Assertions.assertTrue private val logger = KotlinLogging.logger {} -class BaseTestCodeGeneratorPipeline(private val testFrameworkConfiguration: TestFrameworkConfiguration) { +class TestCodeGeneratorPipeline(private val testFrameworkConfiguration: TestFrameworkConfiguration) { fun runClassesCodeGenerationTests(classesStages: List) { val pipelines = classesStages.map { @@ -206,14 +205,13 @@ class BaseTestCodeGeneratorPipeline(private val testFrameworkConfiguration: Test ): String { val params = mutableMapOf, List>() - val modelBasedTestCodeGenerator = with(testFrameworkConfiguration) { - ModelBasedTestCodeGenerator() + val codeGenerator = with(testFrameworkConfiguration) { + CodeGenerator() .apply { init( classUnderTest.java, params = params, testFramework = testFramework, - mockFramework = MockFramework.MOCKITO, staticsMocking = staticsMocking, forceStaticMocking = forceStaticMocking, generateWarningsForStaticMocking = false, @@ -226,7 +224,7 @@ class BaseTestCodeGeneratorPipeline(private val testFrameworkConfiguration: Test } val testClassCustomName = "${classUnderTest.java.simpleName}GeneratedTest" - return modelBasedTestCodeGenerator.generateAsString(testCases, testClassCustomName) + return codeGenerator.generateAsString(testCases, testClassCustomName) } private fun checkPipelinesResults(classesPipelines: List) { @@ -281,7 +279,7 @@ class BaseTestCodeGeneratorPipeline(private val testFrameworkConfiguration: Test val buildDir = FileUtil.isolateClassFiles(it).toPath() val classPath = System.getProperty("java.class.path") val dependencyPath = System.getProperty("java.class.path") - UtBotTestCaseGenerator.init(buildDir, classPath, dependencyPath, isCanceled = { false }) + TestCaseGenerator.init(buildDir, classPath, dependencyPath) val pipelineStages = runPipelinesStages( listOf( @@ -297,8 +295,8 @@ class BaseTestCodeGeneratorPipeline(private val testFrameworkConfiguration: Test companion object { - val CodegenLanguage.defaultCodegenPipeline: BaseTestCodeGeneratorPipeline - get() = BaseTestCodeGeneratorPipeline( + val CodegenLanguage.defaultCodegenPipeline: TestCodeGeneratorPipeline + get() = TestCodeGeneratorPipeline( TestFrameworkConfiguration( testFramework = TestFramework.defaultItem, codegenLanguage = this, @@ -398,12 +396,6 @@ private fun constructPipelineResultCheck( statuses[lastStage] == status } -private fun failed(stage: Stage) = StageStatusCheck(lastStage = stage, status = FAILED) -private fun succeeded(stage: Stage) = StageStatusCheck(lastStage = stage, status = SUCCESS) - -// Everything succeeded because last step succeeded -val everythingSucceeded = succeeded(TestExecution) - data class CompilationResult(val buildDirectory: String, val testClassName: String) /** diff --git a/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/MockStrategyApiTest.kt b/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/MockStrategyApiTest.kt index c53f2868e8..4ce43e1a95 100644 --- a/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/MockStrategyApiTest.kt +++ b/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/MockStrategyApiTest.kt @@ -3,9 +3,24 @@ package org.utbot.framework.plugin.api import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Test +import org.utbot.engine.MockStrategy +import org.utbot.framework.util.toModel internal class MockStrategyApiTest { + @Test + fun testApiToModel() { + assertEquals( + MockStrategyApi.values().size, MockStrategy.values().size, + "The number of strategies in the contract and engine model should match" + ) + + assertEquals(3, MockStrategyApi.values().size, "Three options only (so far)") + assertEquals(MockStrategy.NO_MOCKS, MockStrategyApi.NO_MOCKS.toModel()) + assertEquals(MockStrategy.OTHER_PACKAGES, MockStrategyApi.OTHER_PACKAGES.toModel()) + assertEquals(MockStrategy.OTHER_CLASSES, MockStrategyApi.OTHER_CLASSES.toModel()) + } + @Test fun ensureDefaultStrategyIsOtherPackages() { assertEquals( diff --git a/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGeneratorTest.kt b/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGeneratorTest.kt deleted file mode 100644 index 61dcd67b83..0000000000 --- a/utbot-framework/src/test/kotlin/org/utbot/framework/plugin/api/UtBotTestCaseGeneratorTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package org.utbot.framework.plugin.api - -import org.utbot.engine.MockStrategy -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator.apiToModel -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Test - - -internal class UtBotTestCaseGeneratorTest { - - @Test - fun testApiToModel() { - assertEquals( - MockStrategyApi.values().size, MockStrategy.values().size, - "The number of strategies in the contract and engine model should match" - ) - - assertEquals(3, MockStrategyApi.values().size, "Three options only (so far)") - assertEquals(MockStrategy.NO_MOCKS, apiToModel(MockStrategyApi.NO_MOCKS)) - assertEquals(MockStrategy.OTHER_PACKAGES, apiToModel(MockStrategyApi.OTHER_PACKAGES)) - assertEquals(MockStrategy.OTHER_CLASSES, apiToModel(MockStrategyApi.OTHER_CLASSES)) - } -} \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/TestGenerator.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationProcessor.kt similarity index 82% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/TestGenerator.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationProcessor.kt index 75270ad4e9..c65a3657b9 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/TestGenerator.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerationProcessor.kt @@ -1,23 +1,5 @@ package org.utbot.intellij.plugin.generator -import org.utbot.common.HTML_LINE_SEPARATOR -import org.utbot.common.PathUtil.classFqnToPath -import org.utbot.common.PathUtil.toHtmlLinkTag -import org.utbot.common.appendHtmlLine -import org.utbot.framework.codegen.Import -import org.utbot.framework.codegen.ParametrizedTestSource -import org.utbot.framework.codegen.StaticImport -import org.utbot.framework.codegen.TestsCodeWithTestReport -import org.utbot.framework.codegen.model.ModelBasedTestCodeGenerator -import org.utbot.framework.codegen.model.constructor.tree.TestsGenerationReport -import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.framework.plugin.api.UtTestCase -import org.utbot.intellij.plugin.sarif.SarifReportIdea -import org.utbot.intellij.plugin.sarif.SourceFindingStrategyIdea -import org.utbot.intellij.plugin.settings.Settings -import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath -import org.utbot.intellij.plugin.ui.utils.getOrCreateTestResourcesPath -import org.utbot.sarif.SarifReport import com.intellij.codeInsight.CodeInsightUtil import com.intellij.codeInsight.FileModificationService import com.intellij.ide.fileTemplates.FileTemplateManager @@ -28,26 +10,29 @@ import com.intellij.openapi.application.runReadAction import com.intellij.openapi.application.runWriteAction import com.intellij.openapi.command.WriteCommandAction.runWriteCommandAction import com.intellij.openapi.command.executeCommand -import com.intellij.openapi.components.service import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.openapi.util.Computable import com.intellij.openapi.vfs.VfsUtil -import com.intellij.psi.* +import com.intellij.psi.JavaDirectoryService +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiClassOwner +import com.intellij.psi.PsiDirectory +import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.PsiMethod import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.codeStyle.JavaCodeStyleManager import com.intellij.psi.search.GlobalSearchScopesCore +import com.intellij.refactoring.util.classMembers.MemberInfo import com.intellij.testIntegration.TestIntegrationUtils import com.intellij.util.IncorrectOperationException import com.intellij.util.concurrency.AppExecutorUtil import com.intellij.util.io.exists import com.siyeh.ig.psiutils.ImportUtils -import java.nio.file.Path -import java.nio.file.Paths -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit import org.jetbrains.kotlin.asJava.classes.KtUltraLightClass import org.jetbrains.kotlin.idea.core.ShortenReferences import org.jetbrains.kotlin.idea.core.getPackage @@ -61,33 +46,47 @@ import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.scripting.resolve.classId +import org.utbot.common.HTML_LINE_SEPARATOR +import org.utbot.common.PathUtil.classFqnToPath +import org.utbot.common.PathUtil.toHtmlLinkTag +import org.utbot.common.appendHtmlLine +import org.utbot.framework.codegen.Import +import org.utbot.framework.codegen.ParametrizedTestSource +import org.utbot.framework.codegen.RegularImport +import org.utbot.framework.codegen.StaticImport +import org.utbot.framework.codegen.model.CodeGenerator +import org.utbot.framework.codegen.model.TestsCodeWithTestReport +import org.utbot.framework.codegen.model.constructor.tree.TestsGenerationReport +import org.utbot.framework.plugin.api.CodegenLanguage +import org.utbot.framework.plugin.api.UtMethod +import org.utbot.framework.plugin.api.UtTestCase import org.utbot.framework.plugin.api.util.UtContext import org.utbot.framework.plugin.api.util.withUtContext -import org.utbot.intellij.plugin.error.showErrorDialogLater -import org.utbot.intellij.plugin.generator.TestGenerator.Target.* -import org.utbot.intellij.plugin.ui.GenerateTestsModel +import org.utbot.intellij.plugin.generator.CodeGenerationProcessor.Target.EDT_LATER +import org.utbot.intellij.plugin.generator.CodeGenerationProcessor.Target.READ_ACTION +import org.utbot.intellij.plugin.generator.CodeGenerationProcessor.Target.THREAD_POOL +import org.utbot.intellij.plugin.generator.CodeGenerationProcessor.Target.WRITE_ACTION +import org.utbot.intellij.plugin.models.GenerateTestsModel +import org.utbot.intellij.plugin.models.packageName +import org.utbot.intellij.plugin.sarif.SarifReportIdea +import org.utbot.intellij.plugin.sarif.SourceFindingStrategyIdea import org.utbot.intellij.plugin.ui.SarifReportNotifier import org.utbot.intellij.plugin.ui.TestReportUrlOpeningListener import org.utbot.intellij.plugin.ui.TestsReportNotifier -import org.utbot.intellij.plugin.ui.packageName +import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath +import org.utbot.intellij.plugin.ui.utils.getOrCreateTestResourcesPath +import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater +import org.utbot.intellij.plugin.util.signature +import org.utbot.sarif.SarifReport +import java.nio.file.Path +import java.nio.file.Paths +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit +import kotlin.reflect.KClass +import kotlin.reflect.full.functions -object TestGenerator { - private enum class Target {THREAD_POOL, READ_ACTION, WRITE_ACTION, EDT_LATER} - - private fun run(target: Target, runnable: Runnable) { - UtContext.currentContext()?.let { - when (target) { - THREAD_POOL -> AppExecutorUtil.getAppExecutorService().submit { - withUtContext(it) { - runnable.run() - } - } - READ_ACTION -> runReadAction { withUtContext(it) { runnable.run() } } - WRITE_ACTION -> runWriteAction { withUtContext(it) { runnable.run() } } - EDT_LATER -> invokeLater { withUtContext(it) { runnable.run() } } - } - } ?: error("No context in thread ${Thread.currentThread()}") - } +object CodeGenerationProcessor { + private enum class Target { THREAD_POOL, READ_ACTION, WRITE_ACTION, EDT_LATER } fun generateTests(model: GenerateTestsModel, testCasesByClass: Map>) { val baseTestDirectory = model.testSourceRoot?.toPsiDirectory(model.project) @@ -105,7 +104,7 @@ object TestGenerator { val file = testClass.containingFile runWriteCommandAction(model.project, "Generate tests with UtBot", null, { try { - addTestMethodsAndSaveReports(testClass, file, testCases, model, latch) + generateCodeAndSaveReports(testClass, file, testCases, model, latch) } catch (e: IncorrectOperationException) { showCreatingClassError(model.project, createTestClassName(srcClass)) } @@ -122,7 +121,22 @@ object TestGenerator { } } - private fun waitForCountDown(latch: CountDownLatch, model: GenerateTestsModel, sarifReportsPath : Path) { + private fun run(target: Target, runnable: Runnable) { + UtContext.currentContext()?.let { + when (target) { + THREAD_POOL -> AppExecutorUtil.getAppExecutorService().submit { + withUtContext(it) { + runnable.run() + } + } + READ_ACTION -> runReadAction { withUtContext(it) { runnable.run() } } + WRITE_ACTION -> runWriteAction { withUtContext(it) { runnable.run() } } + EDT_LATER -> invokeLater { withUtContext(it) { runnable.run() } } + } + } ?: error("No context in thread ${Thread.currentThread()}") + } + + private fun waitForCountDown(latch: CountDownLatch, model: GenerateTestsModel, sarifReportsPath: Path) { try { if (!latch.await(5, TimeUnit.SECONDS)) { run(THREAD_POOL) { waitForCountDown(latch, model, sarifReportsPath) } @@ -133,7 +147,7 @@ object TestGenerator { } } - private fun mergeSarifReports(model: GenerateTestsModel, sarifReportsPath : Path) { + private fun mergeSarifReports(model: GenerateTestsModel, sarifReportsPath: Path) { val sarifReports = sarifReportsPath.toFile() .walkTopDown() .filter { it.extension == "sarif" } @@ -218,7 +232,7 @@ object TestGenerator { return (createFromTemplate.containingFile as PsiClassOwner).classes.first() } - private fun addTestMethodsAndSaveReports( + private fun generateCodeAndSaveReports( testClass: PsiClass, file: PsiFile, testCases: List, @@ -234,7 +248,7 @@ object TestGenerator { val params = findMethodParams(classUnderTest, selectedMethods) - val generator = model.project.service().codeGenerator.apply { + val codeGenerator = CodeGenerator().apply { init( classUnderTest = classUnderTest.java, params = params.toMutableMap(), @@ -247,58 +261,53 @@ object TestGenerator { generateWarningsForStaticMocking = model.generateWarningsForStaticMocking, runtimeExceptionTestsBehaviour = model.runtimeExceptionTestsBehaviour, hangingTestsTimeout = model.hangingTestsTimeout, + enableTestsTimeout = true, testClassPackageName = testClass.packageName ) } - when (generator) { - is ModelBasedTestCodeGenerator -> { - val editor = CodeInsightUtil.positionCursorAtLBrace(testClass.project, file, testClass) - //TODO Use PsiDocumentManager.getInstance(model.project).getDocument(file) - // if we don't want to open _all_ new files with tests in editor one-by-one - run(THREAD_POOL) { - val testsCodeWithTestReport = generator.generateAsStringWithTestReport(testCases) - val generatedTestsCode = testsCodeWithTestReport.generatedCode - run(EDT_LATER) { - run(WRITE_ACTION) { - unblockDocument(testClass.project, editor.document) - // TODO: JIRA:1246 - display warnings if we rewrite the file - executeCommand(testClass.project, "Insert Generated Tests") { - editor.document.setText(generatedTestsCode) - } - unblockDocument(testClass.project, editor.document) - - // after committing the document the `testClass` is invalid in PsiTree, - // so we have to reload it from the corresponding `file` - val testClassUpdated = (file as PsiClassOwner).classes.first() // only one class in the file - - // reformatting before creating reports due to - // SarifReport requires the final version of the generated tests code - runWriteCommandAction(testClassUpdated.project, "UtBot tests reformatting", null, { - reformat(model, file, testClassUpdated) - }) - unblockDocument(testClassUpdated.project, editor.document) - - // uploading formatted code - val testsCodeWithTestReportFormatted = - testsCodeWithTestReport.copy(generatedCode = file.text) - - // creating and saving reports - saveSarifAndTestReports( - testClassUpdated, - testCases, - model, - testsCodeWithTestReportFormatted, - reportsCountDown - ) - - unblockDocument(testClassUpdated.project, editor.document) - } + val editor = CodeInsightUtil.positionCursorAtLBrace(testClass.project, file, testClass) + //TODO: Use PsiDocumentManager.getInstance(model.project).getDocument(file) + // if we don't want to open _all_ new files with tests in editor one-by-one + run(THREAD_POOL) { + val testsCodeWithTestReport = codeGenerator.generateAsStringWithTestReport(testCases) + val generatedTestsCode = testsCodeWithTestReport.generatedCode + run(EDT_LATER) { + run(WRITE_ACTION) { + unblockDocument(testClass.project, editor.document) + // TODO: JIRA:1246 - display warnings if we rewrite the file + executeCommand(testClass.project, "Insert Generated Tests") { + editor.document.setText(generatedTestsCode) } + unblockDocument(testClass.project, editor.document) + + // after committing the document the `testClass` is invalid in PsiTree, + // so we have to reload it from the corresponding `file` + val testClassUpdated = (file as PsiClassOwner).classes.first() // only one class in the file + + // reformatting before creating reports due to + // SarifReport requires the final version of the generated tests code + runWriteCommandAction(testClassUpdated.project, "UtBot tests reformatting", null, { + reformat(model, file, testClassUpdated) + }) + unblockDocument(testClassUpdated.project, editor.document) + + // uploading formatted code + val testsCodeWithTestReportFormatted = + testsCodeWithTestReport.copy(generatedCode = file.text) + + // creating and saving reports + saveSarifAndTestReports( + testClassUpdated, + testCases, + model, + testsCodeWithTestReportFormatted, + reportsCountDown + ) + + unblockDocument(testClassUpdated.project, editor.document) } } - //Note that reportsCountDown.countDown() has to be called in every generator implementation to complete whole process - else -> TODO("Only model based code generator supported, but got: ${generator::class}") } } @@ -318,6 +327,17 @@ object TestGenerator { } } + private fun findMethodParams(clazz: KClass<*>, methods: List): Map, List> { + val bySignature = methods.associate { it.signature() to it.paramNames() } + return clazz.functions.mapNotNull { method -> + bySignature[method.signature()]?.let { params -> + UtMethod(method, clazz) to params + } + }.toMap() + } + + private fun MemberInfo.paramNames(): List = + (this.member as PsiMethod).parameterList.parameters.map { it.name } private fun saveSarifAndTestReports( testClass: PsiClass, @@ -376,7 +396,11 @@ object TestGenerator { val fileReportPath = classFqnToPath(classFqn) val resultedReportedPath = - Paths.get(testResourcesDirPath.toString(), testReportSubDir, fileReportPath + "TestReport" + TestsGenerationReport.EXTENSION) + Paths.get( + testResourcesDirPath.toString(), + testReportSubDir, + fileReportPath + "TestReport" + TestsGenerationReport.EXTENSION + ) val parent = resultedReportedPath.parent requireNotNull(parent) { @@ -391,7 +415,8 @@ object TestGenerator { val notifyMessage = buildString { appendHtmlLine(testsCodeWithTestReport.testsGenerationReport.toString()) appendHtmlLine() - val classUnderTestPackageName = testsCodeWithTestReport.testsGenerationReport.classUnderTest.classId.packageFqName.toString() + val classUnderTestPackageName = + testsCodeWithTestReport.testsGenerationReport.classUnderTest.classId.packageFqName.toString() if (classUnderTestPackageName != model.testPackageName) { val warningMessage = """ Warning: Destination package ${model.testPackageName} does not match package of the class $classUnderTestPackageName. @@ -465,6 +490,7 @@ object TestGenerator { ImportUtils.addStaticImport(import.qualifierClass, import.memberName, testClass) } } + is RegularImport -> { } } } } diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerator.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerator.kt deleted file mode 100644 index ea06ea3f1a..0000000000 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/CodeGenerator.kt +++ /dev/null @@ -1,96 +0,0 @@ -package org.utbot.intellij.plugin.generator - -import org.utbot.framework.TestSelectionStrategyType -import org.utbot.framework.UtSettings -import org.utbot.framework.plugin.api.ClassId -import org.utbot.framework.plugin.api.MockStrategyApi -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator -import org.utbot.framework.plugin.api.UtMethod -import org.utbot.framework.plugin.api.UtTestCase -import org.utbot.intellij.plugin.settings.Settings -import org.utbot.summary.summarize -import com.intellij.openapi.components.service -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiMethod -import com.intellij.refactoring.util.classMembers.MemberInfo -import org.utbot.engine.UtBotSymbolicEngine -import java.nio.file.Path -import java.nio.file.Paths -import kotlin.reflect.KClass -import kotlin.reflect.KFunction -import kotlin.reflect.KParameter.Kind -import kotlin.reflect.full.functions -import kotlin.reflect.jvm.javaType - -val logger = Logger.getInstance(CodeGenerator::class.java) - -class CodeGenerator( - private val searchDirectory: Path, - private val mockStrategy: MockStrategyApi, - project: Project, - private val chosenClassesToMockAlways: Set, - buildDir: String, - classpath: String, - pluginJarsPath: String, - engineActions: MutableList<(UtBotSymbolicEngine) -> Unit> = mutableListOf(), - isCanceled: () -> Boolean, -) { - val generator = (project.service().testCasesGenerator as UtBotTestCaseGenerator).apply { - init(Paths.get(buildDir), classpath, pluginJarsPath, engineActions, isCanceled) - } - - private val settingsState = project.service().state - - fun executions(method: UtMethod<*>) = generator.generate(method, mockStrategy).summarize(searchDirectory) - - fun generateForSeveralMethods(methods: List>, timeout:Long = UtSettings.utBotGenerationTimeoutInMillis): List { - logger.info("Tests generating parameters $settingsState") - - return generator - .generateForSeveralMethods(methods, mockStrategy, chosenClassesToMockAlways, methodsGenerationTimeout = timeout) - .map { it.summarize(searchDirectory) } - } -} - -fun findMethodsInClassMatchingSelected(clazz: KClass<*>, selectedMethods: List): List> { - val selectedSignatures = selectedMethods.map { it.signature() } - return clazz.functions - .sortedWith(compareBy { selectedSignatures.indexOf(it.signature()) }) - .filter { it.signature().normalized() in selectedSignatures } - .map { UtMethod(it, clazz) } -} - -fun findMethodParams(clazz: KClass<*>, methods: List): Map, List> { - val bySignature = methods.associate { it.signature() to it.paramNames() } - return clazz.functions.mapNotNull { method -> - bySignature[method.signature()]?.let { params -> - UtMethod(method, clazz) to params - } - }.toMap() -} - -private fun MemberInfo.signature(): Signature = - (this.member as PsiMethod).signature() - -private fun MemberInfo.paramNames(): List = - (this.member as PsiMethod).parameterList.parameters.map { it.name } - -private fun PsiMethod.signature() = - Signature(this.name, this.parameterList.parameters.map { - it.type.canonicalText - .replace("...", "[]") //for PsiEllipsisType - .replace(",", ", ") // to fix cases like Pair -> Pair - }) - -private fun KFunction<*>.signature() = - Signature(this.name, this.parameters.filter { it.kind == Kind.VALUE }.map { it.type.javaType.typeName }) - -data class Signature(val name: String, val parameterTypes: List) { - - fun normalized() = this.copy( - parameterTypes = parameterTypes.map { - it?.replace("$", ".") // normalize names of nested classes - } - ) -} \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/UtTestsDialogProcessor.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt similarity index 71% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/UtTestsDialogProcessor.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt index 540f92fea4..820d7378ac 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/UtTestsDialogProcessor.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt @@ -1,20 +1,5 @@ -package org.utbot.intellij.plugin.ui +package org.utbot.intellij.plugin.generator -import org.utbot.framework.JdkPathService -import org.utbot.framework.UtSettings -import org.utbot.framework.codegen.ParametrizedTestSource -import org.utbot.framework.plugin.api.UtMethod -import org.utbot.framework.plugin.api.UtTestCase -import org.utbot.framework.plugin.api.util.UtContext -import org.utbot.framework.plugin.api.util.withSubstitutionCondition -import org.utbot.framework.plugin.api.util.withUtContext -import org.utbot.intellij.plugin.generator.CodeGenerator -import org.utbot.intellij.plugin.generator.TestGenerator.generateTests -import org.utbot.intellij.plugin.generator.findMethodsInClassMatchingSelected -import org.utbot.intellij.plugin.ui.utils.jdkVersion -import org.utbot.intellij.plugin.ui.utils.testModule -import org.utbot.intellij.plugin.util.AndroidApiHelper -import org.utbot.intellij.plugin.util.PluginJdkPathProvider import com.intellij.compiler.impl.CompositeScope import com.intellij.compiler.impl.OneProjectItemCompileScope import com.intellij.openapi.application.PathManager @@ -33,16 +18,36 @@ import com.intellij.psi.PsiClass import com.intellij.refactoring.util.classMembers.MemberInfo import com.intellij.testIntegration.TestIntegrationUtils import com.intellij.util.concurrency.AppExecutorUtil +import mu.KotlinLogging +import org.jetbrains.kotlin.idea.util.module +import org.utbot.engine.util.mockListeners.ForceMockListener +import org.utbot.framework.JdkPathService +import org.utbot.framework.UtSettings +import org.utbot.framework.codegen.ParametrizedTestSource +import org.utbot.framework.plugin.api.TestCaseGenerator +import org.utbot.framework.plugin.api.UtMethod +import org.utbot.framework.plugin.api.UtTestCase +import org.utbot.framework.plugin.api.util.UtContext +import org.utbot.framework.plugin.api.util.withSubstitutionCondition +import org.utbot.framework.plugin.api.util.withUtContext +import org.utbot.intellij.plugin.generator.CodeGenerationProcessor.generateTests +import org.utbot.intellij.plugin.models.GenerateTestsModel +import org.utbot.intellij.plugin.ui.GenerateTestsDialogWindow +import org.utbot.intellij.plugin.ui.utils.jdkVersion +import org.utbot.intellij.plugin.ui.utils.showErrorDialogLater +import org.utbot.intellij.plugin.ui.utils.testModule +import org.utbot.intellij.plugin.util.AndroidApiHelper +import org.utbot.intellij.plugin.util.PluginJdkPathProvider +import org.utbot.intellij.plugin.util.signature +import org.utbot.summary.summarize import java.io.File import java.net.URLClassLoader import java.nio.file.Path import java.nio.file.Paths import java.util.concurrent.TimeUnit -import mu.KotlinLogging -import org.jetbrains.kotlin.idea.util.module -import org.utbot.engine.util.mockListeners.ForceMockListener import org.utbot.engine.util.mockListeners.ForceStaticMockListener -import org.utbot.intellij.plugin.error.showErrorDialogLater +import kotlin.reflect.KClass +import kotlin.reflect.full.functions object UtTestsDialogProcessor { @@ -155,19 +160,18 @@ object UtTestsDialogProcessor { withSubstitutionCondition(shouldSubstituteStatics) { val mockFrameworkInstalled = model.mockFramework?.isInstalled ?: true - val codeGenerator = CodeGenerator( - searchDirectory = searchDirectory, - mockStrategy = model.mockStrategy, - project = model.project, - buildDir = buildDir, - classpath = classpath, - pluginJarsPath = pluginJarsPath.joinToString(separator = File.pathSeparator), - chosenClassesToMockAlways = model.chosenClassesToMockAlways - ) { indicator.isCanceled } + + val testCaseGenerator = TestCaseGenerator.apply { + init( + Paths.get(buildDir), + classpath, + pluginJarsPath.joinToString(separator = File.pathSeparator), + ) { indicator.isCanceled } + } val forceMockListener = if (!mockFrameworkInstalled) { ForceMockListener().apply { - codeGenerator.generator.engineActions.add { engine -> engine.attachMockListener(this) } + testCaseGenerator.engineActions.add { engine -> engine.attachMockListener(this) } } } else { null @@ -175,15 +179,16 @@ object UtTestsDialogProcessor { val forceStaticMockListener = if (!model.staticsMocking.isConfigured) { ForceStaticMockListener().apply { - codeGenerator.generator.engineActions.add { engine -> engine.attachMockListener(this) } + testCaseGenerator.engineActions.add { engine -> engine.attachMockListener(this) } } } else { null } val notEmptyCases = withUtContext(context) { - codeGenerator - .generateForSeveralMethods(methods, model.timeout) + testCaseGenerator + .generateTestCases(methods, model.mockStrategy, model.chosenClassesToMockAlways, model.timeout) + .map { it.summarize(searchDirectory) } .filterNot { it.executions.isEmpty() && it.errors.isEmpty() } } @@ -232,54 +237,61 @@ object UtTestsDialogProcessor { appendLine("Try to alter test generation configuration, e.g. enable mocking and static mocking.") appendLine("Alternatively, you could try to increase current timeout $timeout sec for generating tests in generation dialog.") } -} + private fun findMethodsInClassMatchingSelected(clazz: KClass<*>, selectedMethods: List): List> { + val selectedSignatures = selectedMethods.map { it.signature() } + return clazz.functions + .sortedWith(compareBy { selectedSignatures.indexOf(it.signature()) }) + .filter { it.signature().normalized() in selectedSignatures } + .map { UtMethod(it, clazz) } + } -internal fun urlClassLoader(classpath: List) = - URLClassLoader(classpath.map { File(it).toURI().toURL() }.toTypedArray()) + private fun urlClassLoader(classpath: List) = + URLClassLoader(classpath.map { File(it).toURI().toURL() }.toTypedArray()) -fun findSrcModule(srcClasses: Set): Module { - val srcModules = srcClasses.mapNotNull { it.module }.distinct() - return when (srcModules.size) { - 0 -> error("Module for source classes not found") - 1 -> srcModules.first() - else -> error("Can not generate tests for classes from different modules") + private fun findSrcModule(srcClasses: Set): Module { + val srcModules = srcClasses.mapNotNull { it.module }.distinct() + return when (srcModules.size) { + 0 -> error("Module for source classes not found") + 1 -> srcModules.first() + else -> error("Can not generate tests for classes from different modules") + } } -} -internal fun findPaths(srcClasses: Set): BuildPaths? { - val srcModule = findSrcModule(srcClasses) - val buildDir = CompilerPaths.getModuleOutputPath(srcModule, false) ?: return null - val pathsList = OrderEnumerator.orderEntries(srcModule).recursively().pathsList - - val (classpath, classpathList) = if (AndroidApiHelper.isAndroidStudio()) { - // Add $JAVA_HOME/jre/lib/rt.jar to path. - // This allows Soot to analyze real java instead of stub version in Android SDK on local machine. - pathsList.add( - System.getenv("JAVA_HOME") + File.separator + Paths.get("jre", "lib", "rt.jar") - ) + private fun findPaths(srcClasses: Set): BuildPaths? { + val srcModule = findSrcModule(srcClasses) + val buildDir = CompilerPaths.getModuleOutputPath(srcModule, false) ?: return null + val pathsList = OrderEnumerator.orderEntries(srcModule).recursively().pathsList + + val (classpath, classpathList) = if (AndroidApiHelper.isAndroidStudio()) { + // Add $JAVA_HOME/jre/lib/rt.jar to path. + // This allows Soot to analyze real java instead of stub version in Android SDK on local machine. + pathsList.add( + System.getenv("JAVA_HOME") + File.separator + Paths.get("jre", "lib", "rt.jar") + ) - // Filter out manifests from classpath. - val filterPredicate = { it: String -> - !it.contains("manifest", ignoreCase = true) + // Filter out manifests from classpath. + val filterPredicate = { it: String -> + !it.contains("manifest", ignoreCase = true) + } + val classpathList = pathsList.pathList.filter(filterPredicate) + val classpath = StringUtil.join(classpathList, File.pathSeparator) + Pair(classpath, classpathList) + } else { + val classpath = pathsList.pathsString + val classpathList = pathsList.pathList + Pair(classpath, classpathList) } - val classpathList = pathsList.pathList.filter(filterPredicate) - val classpath = StringUtil.join(classpathList, File.pathSeparator) - Pair(classpath, classpathList) - } else { - val classpath = pathsList.pathsString - val classpathList = pathsList.pathList - Pair(classpath, classpathList) + val pluginJarsPath = Paths.get(PathManager.getPluginsPath(), "utbot-intellij", "lib").toFile().listFiles() + ?: error("Can't find plugin folder.") + return BuildPaths(buildDir, classpath, classpathList, pluginJarsPath.map { it.path }) } - val pluginJarsPath = Paths.get(PathManager.getPluginsPath(), "utbot-intellij", "lib").toFile().listFiles() - ?: error("Can't find plugin folder.") - return BuildPaths(buildDir, classpath, classpathList, pluginJarsPath.map { it.path }) -} -data class BuildPaths( - val buildDir: String, - val classpath: String, - val classpathList: List, - val pluginJarsPath: List - // ^ TODO: Now we collect ALL dependent libs and pass them to the child process. Most of them are redundant. -) \ No newline at end of file + data class BuildPaths( + val buildDir: String, + val classpath: String, + val classpathList: List, + val pluginJarsPath: List + // ^ TODO: Now we collect ALL dependent libs and pass them to the child process. Most of them are redundant. + ) +} diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/ExternalLibraryDescriptors.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt similarity index 95% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/ExternalLibraryDescriptors.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt index c11e53c7c7..88a4a14533 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/ExternalLibraryDescriptors.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/ExternalLibraryDescriptors.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.ui +package org.utbot.intellij.plugin.models import com.intellij.openapi.roots.ExternalLibraryDescriptor diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsModel.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt similarity index 98% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsModel.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt index b79d916223..a2756ad8d3 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsModel.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/models/GenerateTestsModel.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.ui +package org.utbot.intellij.plugin.models import org.utbot.framework.codegen.ForceStaticMocking import org.utbot.framework.codegen.HangingTestsTimeout diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/sarif/SarifReportIdea.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/sarif/SarifReportIdea.kt index 19e757a190..800a028714 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/sarif/SarifReportIdea.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/sarif/SarifReportIdea.kt @@ -2,10 +2,10 @@ package org.utbot.intellij.plugin.sarif import org.utbot.common.PathUtil.classFqnToPath import org.utbot.framework.plugin.api.UtTestCase -import org.utbot.intellij.plugin.ui.GenerateTestsModel import org.utbot.intellij.plugin.ui.utils.getOrCreateSarifReportsPath import org.utbot.sarif.SarifReport import com.intellij.openapi.vfs.VfsUtil +import org.utbot.intellij.plugin.models.GenerateTestsModel object SarifReportIdea { diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/CodeGeneratorServiceLoader.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/CodeGeneratorServiceLoader.kt deleted file mode 100644 index 4f4b1cbe07..0000000000 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/CodeGeneratorServiceLoader.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.utbot.intellij.plugin.settings - -import org.utbot.framework.codegen.CodeGeneratorService -import org.utbot.framework.codegen.TestCodeGenerator -import org.utbot.framework.plugin.api.UtService -import java.util.ServiceLoader - -object CodeGeneratorServiceLoader : UtServiceLoader() { - override val services: List> - override val defaultService: UtService - - init { - services = withLocalClassLoader { - ServiceLoader.load(CodeGeneratorService::class.java).toList() - } - services.forEach { - serviceByName[it.displayName] = it - } - // TODO: process case when no generator is available - defaultService = services.first() - } -} \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Settings.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Settings.kt index b5c200161b..582821d346 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Settings.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/Settings.kt @@ -2,6 +2,13 @@ package org.utbot.intellij.plugin.settings +import com.intellij.openapi.components.PersistentStateComponent +import com.intellij.openapi.components.State +import com.intellij.openapi.components.Storage +import com.intellij.openapi.project.Project +import com.intellij.util.xmlb.Converter +import com.intellij.util.xmlb.annotations.OptionTag +import org.utbot.common.FileUtil import org.utbot.engine.Mocker import org.utbot.framework.UtSettings import org.utbot.framework.codegen.ForceStaticMocking @@ -13,26 +20,15 @@ import org.utbot.framework.codegen.NoStaticMocking import org.utbot.framework.codegen.ParametrizedTestSource import org.utbot.framework.codegen.RuntimeExceptionTestsBehaviour import org.utbot.framework.codegen.StaticsMocking -import org.utbot.framework.codegen.TestCodeGenerator import org.utbot.framework.codegen.TestFramework import org.utbot.framework.codegen.TestNg -import org.utbot.framework.codegen.model.ModelBasedCodeGeneratorService import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.CodeGenerationSettingItem import org.utbot.framework.plugin.api.CodegenLanguage import org.utbot.framework.plugin.api.MockFramework import org.utbot.framework.plugin.api.MockStrategyApi -import org.utbot.framework.plugin.api.SymbolicEngineTestGeneratorService -import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.TreatOverflowAsError -import org.utbot.intellij.plugin.ui.GenerateTestsModel -import com.intellij.openapi.components.PersistentStateComponent -import com.intellij.openapi.components.State -import com.intellij.openapi.components.Storage -import com.intellij.openapi.project.Project -import com.intellij.util.xmlb.Converter -import com.intellij.util.xmlb.annotations.OptionTag -import org.utbot.common.FileUtil +import org.utbot.intellij.plugin.models.GenerateTestsModel import java.util.concurrent.CompletableFuture import kotlin.reflect.KClass @@ -42,8 +38,6 @@ import kotlin.reflect.KClass ) class Settings(val project: Project) : PersistentStateComponent { data class State( - var generatorName: String = defaultGeneratorName(), - var codeGeneratorName: String = defaultCodeGeneratorName(), var codegenLanguage: CodegenLanguage = CodegenLanguage.defaultItem, @OptionTag(converter = TestFrameworkConverter::class) var testFramework: TestFramework = TestFramework.defaultItem, @@ -78,8 +72,6 @@ class Settings(val project: Project) : PersistentStateComponent other as State - if (generatorName != other.generatorName) return false - if (codeGeneratorName != other.codeGeneratorName) return false if (codegenLanguage != other.codegenLanguage) return false if (testFramework != other.testFramework) return false if (mockStrategy != other.mockStrategy) return false @@ -95,9 +87,7 @@ class Settings(val project: Project) : PersistentStateComponent return true } override fun hashCode(): Int { - var result = generatorName.hashCode() - result = 31 * result + codeGeneratorName.hashCode() - result = 31 * result + codegenLanguage.hashCode() + var result = codegenLanguage.hashCode() result = 31 * result + testFramework.hashCode() result = 31 * result + mockStrategy.hashCode() result = 31 * result + mockFramework.hashCode() @@ -115,16 +105,6 @@ class Settings(val project: Project) : PersistentStateComponent private var state = State() - // TODO: we removed loading from saved settings, but may return to it later - val testCasesGenerator: TestCaseGenerator - get() = defaultTestCaseGenerator() - - // TODO: we removed loading from saved settings, but may return to it later - val codeGenerator: TestCodeGenerator - get() = defaultCodeGenerator() - - val generatorName: String get() = state.generatorName - val codegenLanguage: CodegenLanguage get() = state.codegenLanguage val testFramework: TestFramework get() = state.testFramework @@ -204,18 +184,6 @@ class Settings(val project: Project) : PersistentStateComponent // TODO: add error processing else -> error("Unknown service loader: $loader") } - - companion object { - private fun defaultTestCaseGenerator(): TestCaseGenerator = SymbolicEngineTestGeneratorService().serviceProvider - - private fun defaultCodeGenerator(): TestCodeGenerator = ModelBasedCodeGeneratorService().serviceProvider - - private fun defaultGeneratorName(): String = - TestGeneratorServiceLoader.defaultServiceProviderName - - private fun defaultCodeGeneratorName(): String = - CodeGeneratorServiceLoader.defaultServiceProviderName - } } // use it to serialize testFramework in State diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt index c1501f51c9..07bd771e13 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/SettingsWindow.kt @@ -72,18 +72,6 @@ class SettingsWindow(val project: Project) { } init { - // TODO: service loaders for test generator and code generator are removed from settings temporarily - val serviceLoaderToProviderNames = listOf, Set>>() -// listOf(TestGeneratorServiceLoader, CodeGeneratorServiceLoader).map { -// it to it.serviceProviderNames -// } - serviceLoaderToProviderNames.forEach { (loader, names) -> - val model = DefaultComboBoxModel(names.toTypedArray()).apply { - selectedItem = settings.providerNameByServiceLoader(loader::class) - } - comboBoxes += ComboBoxInfo(loader::class, ComboBox(model)) - } - comboBoxes += ComboBoxInfo( MockStrategyApi::class, mockStrategyComboBox as ComboBox @@ -149,8 +137,6 @@ class SettingsWindow(val project: Project) { private fun labelByServiceLoader(loader: KClass<*>): String = when (loader) { - TestGeneratorServiceLoader::class -> "Test case generator:" - CodeGeneratorServiceLoader::class -> "Code generator:" MockStrategyApi::class -> "Mock strategy: " CodegenLanguage::class -> "Language generation: " RuntimeExceptionTestsBehaviour::class -> "Behavior of the tests producing Runtime exceptions: " diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/TestGeneratorServiceLoader.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/TestGeneratorServiceLoader.kt deleted file mode 100644 index 39fdd6eca8..0000000000 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/TestGeneratorServiceLoader.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.utbot.intellij.plugin.settings - -import org.utbot.framework.plugin.api.TestCaseGenerator -import org.utbot.framework.plugin.api.TestGeneratorService -import org.utbot.framework.plugin.api.UtService -import java.util.ServiceLoader - -object TestGeneratorServiceLoader : UtServiceLoader() { - override val services: List> - override val defaultService: UtService - - init { - services = withLocalClassLoader { - ServiceLoader.load(TestGeneratorService::class.java).toList() - } - services.forEach { - serviceByName[it.displayName] = it - } - // TODO: process case when no generator is available - defaultService = services.first() - } -} \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/UtServiceLoader.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/UtServiceLoader.kt deleted file mode 100644 index 7b97cdc88c..0000000000 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/settings/UtServiceLoader.kt +++ /dev/null @@ -1,31 +0,0 @@ -package org.utbot.intellij.plugin.settings - -import org.utbot.framework.plugin.api.UtService - -abstract class UtServiceLoader { - abstract val services: List> - abstract val defaultService: UtService - protected val serviceByName: MutableMap> = mutableMapOf() - - val defaultServiceProvider: T - get() = defaultService.serviceProvider - - val defaultServiceProviderName: String - get() = defaultService.displayName - - fun serviceProviderByName(name: String): T? = - serviceByName[name]?.serviceProvider - - val serviceProviderNames: Set - get() = serviceByName.keys - - protected inline fun withLocalClassLoader(block: () -> T): T { - val actualClassLoader = Thread.currentThread().contextClassLoader - try { - Thread.currentThread().contextClassLoader = this::class.java.classLoader - return block() - } finally { - Thread.currentThread().contextClassLoader = actualClassLoader - } - } -} \ No newline at end of file diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt index a91b00c0c9..b4dc0e8443 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt @@ -95,8 +95,14 @@ import com.intellij.util.ui.JBUI.Borders.merge import com.intellij.util.ui.JBUI.scale import com.intellij.util.ui.JBUI.size import com.intellij.util.ui.UIUtil +import org.utbot.intellij.plugin.models.GenerateTestsModel +import org.utbot.intellij.plugin.models.jUnit4LibraryDescriptor +import org.utbot.intellij.plugin.models.jUnit5LibraryDescriptor +import org.utbot.intellij.plugin.models.packageName +import org.utbot.intellij.plugin.models.testNgLibraryDescriptor import com.intellij.util.ui.components.BorderLayoutPanel import org.jetbrains.concurrency.Promise +import org.utbot.intellij.plugin.models.mockitoCoreLibraryDescriptor import org.utbot.intellij.plugin.util.AndroidApiHelper import java.awt.BorderLayout import java.awt.Color 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 6b079e094f..d772a07e55 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 @@ -1,6 +1,6 @@ package org.utbot.intellij.plugin.ui.actions -import org.utbot.intellij.plugin.ui.UtTestsDialogProcessor +import org.utbot.intellij.plugin.generator.UtTestsDialogProcessor import org.utbot.intellij.plugin.ui.utils.KotlinPsiElementHandler import org.utbot.intellij.plugin.ui.utils.PsiElementHandler import com.intellij.openapi.actionSystem.AnAction @@ -25,8 +25,8 @@ import java.util.* class GenerateTestsAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return - val psiTargets = getPsiTargets(e) ?: return - UtTestsDialogProcessor.createDialogAndGenerateTests(project, psiTargets.first, psiTargets.second) + val (srcClasses, focusedMethod) = getPsiTargets(e) ?: return + UtTestsDialogProcessor.createDialogAndGenerateTests(project, srcClasses, focusedMethod) } override fun update(e: AnActionEvent) { diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt index c473054696..49831078e7 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/components/TestFolderComboWithBrowseButton.kt @@ -15,7 +15,7 @@ import javax.swing.DefaultComboBoxModel import javax.swing.JList import org.utbot.common.PathUtil import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.intellij.plugin.ui.GenerateTestsModel +import org.utbot.intellij.plugin.models.GenerateTestsModel import org.utbot.intellij.plugin.ui.utils.addDedicatedTestRoot import org.utbot.intellij.plugin.ui.utils.suitableTestSourceRoots diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/error/ErrorUtils.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ErrorUtils.kt similarity index 87% rename from utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/error/ErrorUtils.kt rename to utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ErrorUtils.kt index 1fe7945adb..948bb9344a 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/error/ErrorUtils.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/utils/ErrorUtils.kt @@ -1,4 +1,4 @@ -package org.utbot.intellij.plugin.error +package org.utbot.intellij.plugin.ui.utils import com.intellij.openapi.application.invokeLater import com.intellij.openapi.project.Project diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/util/SignaturesHelper.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/util/SignaturesHelper.kt new file mode 100644 index 0000000000..a3f9497faa --- /dev/null +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/util/SignaturesHelper.kt @@ -0,0 +1,29 @@ +package org.utbot.intellij.plugin.util + +import com.intellij.psi.PsiMethod +import com.intellij.refactoring.util.classMembers.MemberInfo +import kotlin.reflect.KFunction +import kotlin.reflect.KParameter +import kotlin.reflect.jvm.javaType + +fun MemberInfo.signature(): Signature = + (this.member as PsiMethod).signature() + +fun PsiMethod.signature() = + Signature(this.name, this.parameterList.parameters.map { + it.type.canonicalText + .replace("...", "[]") //for PsiEllipsisType + .replace(",", ", ") // to fix cases like Pair -> Pair + }) + +fun KFunction<*>.signature() = + Signature(this.name, this.parameters.filter { it.kind == KParameter.Kind.VALUE }.map { it.type.javaType.typeName }) + +data class Signature(val name: String, val parameterTypes: List) { + + fun normalized() = this.copy( + parameterTypes = parameterTypes.map { + it?.replace("$", ".") // normalize names of nested classes + } + ) +} \ No newline at end of file diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt index 9460a04ea5..5cb32693eb 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt @@ -1,5 +1,22 @@ package org.utbot.contest +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.ObsoleteCoroutinesApi +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.currentCoroutineContext +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.isActive +import kotlinx.coroutines.job +import kotlinx.coroutines.launch +import kotlinx.coroutines.newSingleThreadContext +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withTimeoutOrNull +import kotlinx.coroutines.yield +import mu.KotlinLogging +import org.apache.commons.io.FileUtils import org.utbot.common.bracket import org.utbot.common.info import org.utbot.engine.EngineController @@ -9,11 +26,10 @@ import org.utbot.framework.UtSettings import org.utbot.framework.codegen.ForceStaticMocking import org.utbot.framework.codegen.StaticsMocking import org.utbot.framework.codegen.junitByVersion -import org.utbot.framework.codegen.model.ModelBasedTestCodeGenerator +import org.utbot.framework.codegen.model.CodeGenerator import org.utbot.framework.plugin.api.CodegenLanguage -import org.utbot.framework.plugin.api.MockFramework import org.utbot.framework.plugin.api.MockStrategyApi -import org.utbot.framework.plugin.api.UtBotTestCaseGenerator +import org.utbot.framework.plugin.api.TestCaseGenerator import org.utbot.framework.plugin.api.UtError import org.utbot.framework.plugin.api.UtExecution import org.utbot.framework.plugin.api.UtMethod @@ -49,23 +65,6 @@ import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaConstructor import kotlin.reflect.jvm.javaGetter import kotlin.reflect.jvm.javaMethod -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.ObsoleteCoroutinesApi -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.currentCoroutineContext -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.isActive -import kotlinx.coroutines.job -import kotlinx.coroutines.launch -import kotlinx.coroutines.newSingleThreadContext -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withTimeoutOrNull -import kotlinx.coroutines.yield -import mu.KotlinLogging -import org.apache.commons.io.FileUtils internal const val junitVersion = 4 private val logger = KotlinLogging.logger {} @@ -124,7 +123,7 @@ fun main(args: Array) { withUtContext(context) { //soot initialization - UtBotTestCaseGenerator.init(classfileDir, classpathString, dependencyPath) + TestCaseGenerator.init(classfileDir, classpathString, dependencyPath) logger.info().bracket("warmup: kotlin reflection :: init") { prepareClass(ConcreteExecutorPool::class, "") @@ -180,7 +179,7 @@ fun runGeneration( - val testCases: MutableMap = mutableMapOf() + val testCases: MutableList = mutableListOf() val currentContext = utContext val timeBudgetMs = timeLimitSec * 1000 @@ -196,7 +195,7 @@ fun runGeneration( setOptions() //will not be executed in real contest logger.info().bracket("warmup: 1st optional soot initialization and executor warmup (not to be counted in time budget)") { - UtBotTestCaseGenerator.init(cut.classfileDir.toPath(), classpathString, dependencyPath) + TestCaseGenerator.init(cut.classfileDir.toPath(), classpathString, dependencyPath) } logger.info().bracket("warmup (first): kotlin reflection :: init") { prepareClass(ConcreteExecutorPool::class, "") @@ -217,13 +216,10 @@ fun runGeneration( val statsForClass = StatsForClass() - // TODO: this generates not only test method, but also imports, etc - // TODO: replace it by a more lightweight code generator - val codeGenerator = ModelBasedTestCodeGenerator().also { - it.init( + val codeGenerator = CodeGenerator().apply { + init( cut.classId.jClass, testFramework = junitByVersion(junitVersion), - mockFramework = MockFramework.MOCKITO, staticsMocking = staticsMocking, forceStaticMocking = forceStaticMocking, generateWarningsForStaticMocking = false @@ -254,9 +250,9 @@ fun runGeneration( // nothing to process further if (filteredMethods.isEmpty()) return@runBlocking statsForClass - val generator = UtBotTestCaseGenerator + val testCaseGenerator = TestCaseGenerator logger.info().bracket("2nd optional soot initialization") { - generator.init(cut.classfileDir.toPath(), classpathString, dependencyPath) + testCaseGenerator.init(cut.classfileDir.toPath(), classpathString, dependencyPath) } @@ -322,7 +318,7 @@ fun runGeneration( } - var testCounter = 0 + var testsCounter = 0 logger.info().bracket("method $method", { statsForMethod }) { logger.info { " -- Remaining time budget: $remainingBudget ms, " + @@ -335,18 +331,17 @@ fun runGeneration( } - generator.generateAsync(controller, method, mockStrategyApi) + testCaseGenerator.generateTestCasesAsync(controller, method, mockStrategyApi) .collect { result -> when (result) { is UtExecution -> { try { - val testCase = UtTestCase(method, listOf(result)) - val newName = testMethodName(testCase.method.toString(), ++testCounter) - logger.debug { "--new testCase collected, to generate: $newName" } - statsForMethod.testcasesGeneratedCount++ - - testCases[newName] = testCase + val testMethodName = testMethodName(method.toString(), ++testsCounter) + logger.debug { "--new testCase collected, to generate: $testMethodName" } + statsForMethod.testsGeneratedCount++ + //TODO: it is a strange hack to create fake test case for one [UtResult] + testCases.add(UtTestCase(method, listOf(result))) } catch (e: Throwable) { //Here we need isolation logger.error(e) { "Code generation failed" } @@ -399,7 +394,7 @@ fun runGeneration( cancellator.cancel() logger.info().bracket("Flushing tests for [${cut.simpleName}] on disk") { - writeTestClass(cut, codeGenerator.generateAsString(testCases.values)) + writeTestClass(cut, codeGenerator.generateAsString(testCases)) } //write classes } @@ -437,7 +432,7 @@ private fun ConcreteExecutor, CoverageInstrumentation>.executeTestCase val staticEnvironment = StaticEnvironment( execution.stateBefore.statics.map { it.key to it.value.value } ) - this.execute(method, *args.toTypedArray(), parameters = staticEnvironment) + this.execute(method, args.toTypedArray(), parameters = staticEnvironment) } } diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Statistics.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Statistics.kt index f48fb2b6f3..5ae9276c33 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Statistics.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Statistics.kt @@ -19,7 +19,7 @@ class GlobalStats { "\n\t#classes canceled by timeout = ${statsForClasses.count { it.canceledByTimeout }}" + "\n----------------------------------------" + "\n\t#total methods for generation = ${statsForClasses.sumBy { it.methodsCount }}" + - "\n\t#methods with at least one testcase generated = ${statsForClasses.sumBy { it.statsForMethods.count { it.testcasesGeneratedCount > 0 } }} " + + "\n\t#methods with at least one testcase generated = ${statsForClasses.sumBy { it.statsForMethods.count { it.testsGeneratedCount > 0 } }} " + "\n\t#methods with exceptions = ${statsForClasses.sumBy { clazz -> clazz.statsForMethods.count { it.failReasons.isNotEmpty() } }}" + "\n\t#suspicious methods WITH NO testcases AND NO exceptions = ${statsForClasses.sumBy { it.statsForMethods.count { it.isSuspicious } }} " + "\n----------------------------------------" + @@ -49,7 +49,7 @@ class StatsForClass { var testClassFile: File? = null val methodsWithAtLeastOneException: Int get() = statsForMethods.count { it.failReasons.isNotEmpty() } - val testcasesGenerated: Int get() = statsForMethods.sumBy { it.testcasesGeneratedCount } + val testcasesGenerated: Int get() = statsForMethods.sumBy { it.testsGeneratedCount } var coverage: CoverageInfo? = null @@ -57,7 +57,7 @@ class StatsForClass { "\n\tcanceled by timeout = $canceledByTimeout" + "\n\t#methods = $methodsCount, " + "\n\t#methods started symbolic exploration = ${statsForMethods.size}" + - "\n\t#methods with at least one TC = ${statsForMethods.count { it.testcasesGeneratedCount > 0 }}" + + "\n\t#methods with at least one TC = ${statsForMethods.count { it.testsGeneratedCount > 0 }}" + "\n\t#methods with exceptions = $methodsWithAtLeastOneException" + "\n\t#generated TC = $testcasesGenerated" + "\n\t#coverage = $coverage" @@ -65,16 +65,16 @@ class StatsForClass { class StatsForMethod(val methodName: String) { - var testcasesGeneratedCount = 0 + var testsGeneratedCount = 0 val failReasons: MutableMultiset = mutableMultisetOf() //generated no TC, nor exception - val isSuspicious: Boolean get() = failReasons.isEmpty() && testcasesGeneratedCount == 0 + val isSuspicious: Boolean get() = failReasons.isEmpty() && testsGeneratedCount == 0 override fun toString(): String = "\n :" + (if (isSuspicious) " SUSPICIOUS" else "") + - "\n\t#generatedTC=$testcasesGeneratedCount\n\t" + + "\n\t#generatedTC=$testsGeneratedCount\n\t" + (if (failReasons.isEmpty()) "WITH NO EXCEPTIONS" else "FAILED ${failReasons.sumOfMultiplicities} time(s) with ${failReasons.size} different exception(s)\"") diff --git a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt index 5ba1fb5dab..8f6470dee1 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt @@ -3,7 +3,7 @@ package examples import org.junit.jupiter.api.* import org.utbot.common.WorkaroundReason import org.utbot.common.workaround -import org.utbot.examples.AbstractTestCaseGeneratorTest +import org.utbot.examples.UtTestCaseChecker import org.utbot.examples.CoverageMatcher import org.utbot.examples.DoNotCalculate import org.utbot.framework.UtSettings.checkNpeInNestedMethods @@ -33,7 +33,7 @@ open class SummaryTestCaseGeneratorTest( CodeGenerationLanguageLastStage(CodegenLanguage.JAVA), CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, TestExecution) ) -) : AbstractTestCaseGeneratorTest(testClass, testCodeGeneration, languagePipelines) { +) : UtTestCaseChecker(testClass, testCodeGeneration, languagePipelines) { private lateinit var cookie: AutoCloseable @BeforeEach