From 5feee74b8b9925b8737fa02da3a63542f7e7a0b1 Mon Sep 17 00:00:00 2001 From: Egor Kulikov Date: Tue, 28 Mar 2023 12:04:26 +0300 Subject: [PATCH] Static methods mocking fix --- .../org/utbot/engine/UtBotSymbolicEngine.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 7efaed85ee..87c54616e7 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt @@ -517,6 +517,20 @@ class UtBotSymbolicEngine( return } + if (checkStaticMethodsMock(symbolicUtExecution)) { + logger.debug { + buildString { + append("processResult<${methodUnderTest}>: library static methods mock found ") + append("(we do not support it in concrete execution yet), ") + append("emit purely symbolic result $symbolicUtExecution") + } + } + + emit(symbolicUtExecution) + return + } + + //It's possible that symbolic and concrete stateAfter/results are diverged. //So we trust concrete results more. try { @@ -648,3 +662,6 @@ private fun UtConcreteExecutionResult.violatesUtMockAssumption(): Boolean { // so we can't cast them to each other. return result.exceptionOrNull()?.javaClass?.name == UtMockAssumptionViolatedException::class.java.name } + +private fun checkStaticMethodsMock(execution: UtSymbolicExecution) = + execution.instrumentation.any { it is UtStaticMethodInstrumentation} \ No newline at end of file