@@ -248,6 +248,11 @@ class UtBotSymbolicEngine(
248248 val concreteExecutionResult =
249249 concreteExecutor.executeConcretely(methodUnderTest, stateBefore, instrumentation)
250250
251+ if (concreteExecutionResult.violatesUtMockAssumption()) {
252+ logger.debug { " Generated test case violates the UtMock assumption: $concreteExecutionResult " }
253+ return @bracket
254+ }
255+
251256 val concreteUtExecution = UtSymbolicExecution (
252257 stateBefore,
253258 concreteExecutionResult.stateAfter,
@@ -368,8 +373,8 @@ class UtBotSymbolicEngine(
368373 // in case an exception occurred from the concrete execution
369374 concreteExecutionResult ? : return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
370375
371- if (concreteExecutionResult.result.exceptionOrNull() is UtMockAssumptionViolatedException ) {
372- logger.debug { " Generated test case by fuzzer violates the UtMock assumption" }
376+ if (concreteExecutionResult.violatesUtMockAssumption() ) {
377+ logger.debug { " Generated test case by fuzzer violates the UtMock assumption: $concreteExecutionResult " }
373378 return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
374379 }
375380
@@ -497,6 +502,11 @@ class UtBotSymbolicEngine(
497502 instrumentation
498503 )
499504
505+ if (concreteExecutionResult.violatesUtMockAssumption()) {
506+ logger.debug { " Generated test case violates the UtMock assumption: $concreteExecutionResult " }
507+ return
508+ }
509+
500510 val concolicUtExecution = symbolicUtExecution.copy(
501511 stateAfter = concreteExecutionResult.stateAfter,
502512 result = concreteExecutionResult.result,
@@ -593,3 +603,11 @@ private fun makeWrapperConsistencyCheck(
593603 val visitedSelectExpression = memory.isVisited(symbolicValue.addr)
594604 visitedConstraints + = mkEq(visitedSelectExpression, mkInt(1 ))
595605}
606+
607+ private fun UtConcreteExecutionResult.violatesUtMockAssumption (): Boolean {
608+ // We should compare FQNs instead of `if (... is UtMockAssumptionViolatedException)`
609+ // because the exception from the `concreteExecutionResult` is loaded by user's ClassLoader,
610+ // but the `UtMockAssumptionViolatedException` is loaded by the current ClassLoader,
611+ // so we can't cast them to each other.
612+ return result.exceptionOrNull()?.javaClass?.name == UtMockAssumptionViolatedException ::class .java.name
613+ }
0 commit comments