Skip to content

Commit 7423224

Browse files
committed
Refix UtMock assume for fuzzer
1 parent 651ecca commit 7423224

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.utbot.api.exception;
22

33
public class UtMockAssumptionViolatedException extends RuntimeException {
4+
5+
public static final String errorMessage = "UtMock assumption violated";
6+
47
@Override
58
public String getMessage() {
6-
return "UtMock assumption violated";
9+
return errorMessage;
710
}
811
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ class UtBotSymbolicEngine(
368368
// in case an exception occurred from the concrete execution
369369
concreteExecutionResult ?: return@runJavaFuzzing BaseFeedback(result = Trie.emptyNode(), control = Control.PASS)
370370

371-
if (concreteExecutionResult.result.exceptionOrNull() is UtMockAssumptionViolatedException) {
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) {
372376
logger.debug { "Generated test case by fuzzer violates the UtMock assumption" }
373377
return@runJavaFuzzing BaseFeedback(result = Trie.emptyNode(), control = Control.PASS)
374378
}

0 commit comments

Comments
 (0)