diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt index d64f54c186..622c3eb534 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/domain/Domain.kt @@ -190,6 +190,8 @@ abstract class TestFramework( open val testSuperClass: ClassId? = null + open val assertSame by lazy { assertionId("assertSame", objectClassId, objectClassId) } + open val assertEquals by lazy { assertionId("assertEquals", objectClassId, objectClassId) } val assertFloatEquals by lazy { assertionId("assertEquals", floatClassId, floatClassId, floatClassId) } diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/TestFrameworkManager.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/TestFrameworkManager.kt index 18c1068bdb..6294be3d2a 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/TestFrameworkManager.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/services/framework/TestFrameworkManager.kt @@ -44,6 +44,8 @@ abstract class TestFrameworkManager(val context: CgContext) val assertions = context.testFramework.assertionsClass + val assertSame = context.testFramework.assertSame + val assertEquals = context.testFramework.assertEquals val assertFloatEquals = context.testFramework.assertFloatEquals val assertDoubleEquals = context.testFramework.assertDoubleEquals @@ -86,6 +88,10 @@ abstract class TestFrameworkManager(val context: CgContext) +assertions[assertEquals](expected, actual) } + open fun assertSame(expected: CgValue, actual: CgValue) { + +assertions[assertSame](expected, actual) + } + open fun assertFloatEquals(expected: CgExpression, actual: CgExpression, delta: Any) { +assertions[assertFloatEquals](expected, actual, delta) } diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt index 72d5a601e1..cc709f84ea 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt @@ -115,6 +115,7 @@ import org.utbot.framework.plugin.api.UtSymbolicExecution import org.utbot.framework.plugin.api.UtTaintAnalysisFailure import org.utbot.framework.plugin.api.UtTimeoutException import org.utbot.framework.plugin.api.UtVoidModel +import org.utbot.framework.plugin.api.isMockModel import org.utbot.framework.plugin.api.isNotNull import org.utbot.framework.plugin.api.isNull import org.utbot.framework.plugin.api.onFailure @@ -618,6 +619,11 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte visitedModels += modelWithField with(testFrameworkManager) { + if (expectedModel.isMockModel()) { + currentBlock += assertions[assertSame](expected, actual).toStatement() + return + } + if (depth >= DEEP_EQUALS_MAX_DEPTH) { currentBlock += CgSingleLineComment("Current deep equals depth exceeds max depth $DEEP_EQUALS_MAX_DEPTH") currentBlock += getDeepEqualsAssertion(expected, actual).toStatement() diff --git a/utbot-js/src/main/kotlin/framework/codegen/model/constructor/tree/JsTestFrameworkManager.kt b/utbot-js/src/main/kotlin/framework/codegen/model/constructor/tree/JsTestFrameworkManager.kt index f7490fd439..13466f194e 100644 --- a/utbot-js/src/main/kotlin/framework/codegen/model/constructor/tree/JsTestFrameworkManager.kt +++ b/utbot-js/src/main/kotlin/framework/codegen/model/constructor/tree/JsTestFrameworkManager.kt @@ -51,6 +51,10 @@ class MochaManager(context: CgContext) : TestFrameworkManager(context) { +assertions[jsAssertEquals](expected, actual) } + override fun assertSame(expected: CgValue, actual: CgValue) { + error("assertSame does not exist in Mocha") + } + override fun disableTestMethod(reason: String) { } diff --git a/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt b/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt index 8726c9af13..cce442c13a 100644 --- a/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt +++ b/utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonTestFrameworkManager.kt @@ -81,6 +81,10 @@ internal class PytestManager(context: CgContext) : TestFrameworkManager(context) ) } + override fun assertSame(expected: CgValue, actual: CgValue) { + error("assertSame does not exist in PyTest") + } + fun assertIsinstance(types: List, actual: CgVariable) { +CgPythonAssertEquals( CgPythonFunctionCall( @@ -102,12 +106,16 @@ internal class UnittestManager(context: CgContext) : TestFrameworkManager(contex override val isExpectedExceptionExecutionBreaking: Boolean = true override val dataProviderMethodsHolder: TestClassContext - get() = error("Parametrized tests are not supported for JavaScript") + get() = error("Parametrized tests are not supported in Unittest") override fun addAnnotationForNestedClasses() { error("Nested classes annotation does not exist in Unittest") } + override fun assertSame(expected: CgValue, actual: CgValue) { + error("assertSame does not exist in Unittest") + } + override fun expectException(exception: ClassId, block: () -> Unit) { require(testFramework is Unittest) { "According to settings, Unittest was expected, but got: $testFramework" } require(exception is PythonClassId) { "Exceptions must be PythonClassId" }