@@ -248,6 +248,11 @@ class UtBotSymbolicEngine(
248
248
val concreteExecutionResult =
249
249
concreteExecutor.executeConcretely(methodUnderTest, stateBefore, instrumentation)
250
250
251
+ if (concreteExecutionResult.violatesUtMockAssumption()) {
252
+ logger.debug { " Generated test case violates the UtMock assumption: $concreteExecutionResult " }
253
+ return @bracket
254
+ }
255
+
251
256
val concreteUtExecution = UtSymbolicExecution (
252
257
stateBefore,
253
258
concreteExecutionResult.stateAfter,
@@ -368,8 +373,8 @@ class UtBotSymbolicEngine(
368
373
// in case an exception occurred from the concrete execution
369
374
concreteExecutionResult ? : return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
370
375
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 " }
373
378
return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
374
379
}
375
380
@@ -497,6 +502,11 @@ class UtBotSymbolicEngine(
497
502
instrumentation
498
503
)
499
504
505
+ if (concreteExecutionResult.violatesUtMockAssumption()) {
506
+ logger.debug { " Generated test case violates the UtMock assumption: $concreteExecutionResult " }
507
+ return
508
+ }
509
+
500
510
val concolicUtExecution = symbolicUtExecution.copy(
501
511
stateAfter = concreteExecutionResult.stateAfter,
502
512
result = concreteExecutionResult.result,
@@ -593,3 +603,11 @@ private fun makeWrapperConsistencyCheck(
593
603
val visitedSelectExpression = memory.isVisited(symbolicValue.addr)
594
604
visitedConstraints + = mkEq(visitedSelectExpression, mkInt(1 ))
595
605
}
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