@@ -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,12 +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- // We should compare messages instead of `if (... is UtMockAssumptionViolatedException)`
372- // because the exception from the `concreteExecutionResult` is loaded by user's ClassLoader,
373- // but the `UtMockAssumptionViolatedException` is loaded by the current ClassLoader,
374- // so we can't cast them to each other.
375- if (concreteExecutionResult.result.exceptionOrNull()?.message == UtMockAssumptionViolatedException .errorMessage) {
376- 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 " }
377378 return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
378379 }
379380
@@ -501,6 +502,11 @@ class UtBotSymbolicEngine(
501502 instrumentation
502503 )
503504
505+ if (concreteExecutionResult.violatesUtMockAssumption()) {
506+ logger.debug { " Generated test case violates the UtMock assumption: $concreteExecutionResult " }
507+ return
508+ }
509+
504510 val concolicUtExecution = symbolicUtExecution.copy(
505511 stateAfter = concreteExecutionResult.stateAfter,
506512 result = concreteExecutionResult.result,
@@ -597,3 +603,11 @@ private fun makeWrapperConsistencyCheck(
597603 val visitedSelectExpression = memory.isVisited(symbolicValue.addr)
598604 visitedConstraints + = mkEq(visitedSelectExpression, mkInt(1 ))
599605}
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