Skip to content

Commit 585c62d

Browse files
Static methods mocking fix #456 (#2054)
1 parent 71a71e1 commit 585c62d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/UtBotSymbolicEngine.kt

+17
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,20 @@ class UtBotSymbolicEngine(
517517
return
518518
}
519519

520+
if (checkStaticMethodsMock(symbolicUtExecution)) {
521+
logger.debug {
522+
buildString {
523+
append("processResult<${methodUnderTest}>: library static methods mock found ")
524+
append("(we do not support it in concrete execution yet), ")
525+
append("emit purely symbolic result $symbolicUtExecution")
526+
}
527+
}
528+
529+
emit(symbolicUtExecution)
530+
return
531+
}
532+
533+
520534
//It's possible that symbolic and concrete stateAfter/results are diverged.
521535
//So we trust concrete results more.
522536
try {
@@ -648,3 +662,6 @@ private fun UtConcreteExecutionResult.violatesUtMockAssumption(): Boolean {
648662
// so we can't cast them to each other.
649663
return result.exceptionOrNull()?.javaClass?.name == UtMockAssumptionViolatedException::class.java.name
650664
}
665+
666+
private fun checkStaticMethodsMock(execution: UtSymbolicExecution) =
667+
execution.instrumentation.any { it is UtStaticMethodInstrumentation}

0 commit comments

Comments
 (0)