diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt index 61a77517dd..5a341c3834 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt @@ -39,6 +39,7 @@ import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.MethodId import org.utbot.framework.plugin.api.UtExecutionSuccess import org.utbot.framework.plugin.api.UtMethodTestSet +import org.utbot.framework.plugin.api.UtSymbolicExecution import org.utbot.framework.plugin.api.util.description import org.utbot.framework.plugin.api.util.humanReadableName import org.utbot.fuzzer.UtFuzzedExecution @@ -211,18 +212,35 @@ internal class CgTestClassConstructor(val context: CgContext) : ) } + regions += CgSimpleRegion( + "Tests for method ${methodUnderTest.humanReadableName} that cannot be presented as parameterized", + collectAdditionalTestsForParameterizedMode(testSet), + ) + } + + private fun collectAdditionalTestsForParameterizedMode(testSet: CgMethodTestSet): List { + val (methodUnderTest, _, _, _) = testSet + val testCaseTestMethods = mutableListOf() + // We cannot track mocking in fuzzed executions, // so we generate standard tests for each [UtFuzzedExecution]. // [https://github.com/UnitTestBot/UTBotJava/issues/1137] - val testCaseTestMethods = mutableListOf() - for (execution in testSet.executions.filterIsInstance()) { - testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution) - } + testSet.executions + .filterIsInstance() + .forEach { execution -> + testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution) + } - regions += CgSimpleRegion( - "FUZZER: EXECUTIONS for method ${methodUnderTest.humanReadableName}", - testCaseTestMethods, - ) + // Also, we generate standard tests for symbolic executions with force mocking. + // [https://github.com/UnitTestBot/UTBotJava/issues/1231] + testSet.executions + .filterIsInstance() + .filter { it.containsMocking } + .forEach { execution -> + testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution) + } + + return testCaseTestMethods } /**