diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt index d8c37c51bd..8bd36ad50f 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt @@ -1367,7 +1367,9 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c substituteStaticFields(statics, isParametrized = true) // build this instance - thisInstance = genericExecution.stateBefore.thisInstance?.let { currentMethodParameters[CgParameterKind.ThisInstance] } + thisInstance = genericExecution.stateBefore.thisInstance?.let { + variableConstructor.getOrCreateVariable(it) + } // build arguments for method under test and parameterized test for (index in genericExecution.stateBefore.parameters.indices) { @@ -1429,20 +1431,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c val executableUnderTestParameters = testSet.executableId.executable.parameters return mutableListOf().apply { - // this instance - val thisInstanceModel = genericExecution.stateBefore.thisInstance - if (thisInstanceModel != null) { - val type = wrapTypeIfRequired(thisInstanceModel.classId) - val thisInstance = CgParameterDeclaration( - parameter = declareParameter( - type = type, - name = nameGenerator.variableName(type) - ), - isReferenceType = true - ) - this += thisInstance - currentMethodParameters[CgParameterKind.ThisInstance] = thisInstance.parameter - } // arguments for (index in genericExecution.stateBefore.parameters.indices) { val argumentName = paramNames[executableUnderTest]?.get(index) @@ -1554,9 +1542,6 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c private fun createExecutionArguments(testSet: CgMethodTestSet, execution: UtExecution): List { val arguments = mutableListOf() - execution.stateBefore.thisInstance?.let { - arguments += variableConstructor.getOrCreateVariable(it) - } for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) { val argumentName = paramNames[testSet.executableId]?.get(paramIndex) diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/tree/CgElement.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/tree/CgElement.kt index 31aca4d64a..05952f59f9 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/tree/CgElement.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/tree/CgElement.kt @@ -745,13 +745,11 @@ data class CgParameterDeclaration( /** * Test method parameter can be one of the following types: - * - this instance for method under test (MUT) * - argument of MUT with a certain index * - result expected from MUT with the given arguments * - exception expected from MUT with the given arguments */ sealed class CgParameterKind { - object ThisInstance : CgParameterKind() data class Argument(val index: Int) : CgParameterKind() data class Statics(val model: UtModel) : CgParameterKind() object ExpectedResult : CgParameterKind() diff --git a/utbot-framework/src/main/kotlin/org/utbot/tests/infrastructure/CheckersUtil.kt b/utbot-framework/src/main/kotlin/org/utbot/tests/infrastructure/CheckersUtil.kt index 093d9a73bd..a59fa685f3 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/tests/infrastructure/CheckersUtil.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/tests/infrastructure/CheckersUtil.kt @@ -52,6 +52,9 @@ data class TestFrameworkConfiguration( // junit4 doesn't support parametrized tests if (testFramework == Junit4 && parametrizedTestSource == ParametrizedTestSource.PARAMETRIZE) return true + //if we do not use mocks at all, we do not use static mocking too + if (mockStrategy == NO_MOCKS && staticsMocking == MockitoStaticMocking) return true + // if we want to generate mocks for every class but CUT, we must have specified staticsMocking if (mockStrategy == OTHER_CLASSES && staticsMocking == NoStaticMocking) return true