File tree Expand file tree Collapse file tree 4 files changed +18
-2
lines changed
utbot-api/src/main/java/org/utbot/api
utbot-framework/src/main/kotlin/org/utbot/engine
utbot-sample/src/main/resources Expand file tree Collapse file tree 4 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1+ package org .utbot .api .exception ;
2+
3+ public class UtMockAssumptionViolatedException extends RuntimeException {
4+ @ Override
5+ public String getMessage () {
6+ return "UtMock assumption violated" ;
7+ }
8+ }
Original file line number Diff line number Diff line change 11package org .utbot .api .mock ;
22
3+ import org .utbot .api .exception .UtMockAssumptionViolatedException ;
4+
35public class UtMock {
46 public static <T > T makeSymbolic () {
57 return makeSymbolic (false );
@@ -14,14 +16,14 @@ public static <T> T makeSymbolic(boolean isNullable) {
1416 public static void assume (boolean predicate ) {
1517 // to use compilers checks, i.e. for possible NPE
1618 if (!predicate ) {
17- throw new RuntimeException ();
19+ throw new UtMockAssumptionViolatedException ();
1820 }
1921 }
2022
2123 @ SuppressWarnings ("unused" )
2224 public static void assumeOrExecuteConcretely (boolean predicate ) {
2325 // In oppose to assume, we don't have predicate check here
24- // to avoid RuntimeException during concrete execution
26+ // to avoid UtMockAssumptionViolatedException during concrete execution
2527 }
2628
2729 @ SuppressWarnings ("unused" )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import mu.KotlinLogging
77import org.utbot.analytics.EngineAnalyticsContext
88import org.utbot.analytics.FeatureProcessor
99import org.utbot.analytics.Predictors
10+ import org.utbot.api.exception.UtMockAssumptionViolatedException
1011import org.utbot.common.bracket
1112import org.utbot.common.debug
1213import org.utbot.engine.MockStrategy.NO_MOCKS
@@ -366,6 +367,11 @@ class UtBotSymbolicEngine(
366367 // in case an exception occurred from the concrete execution
367368 concreteExecutionResult ? : return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
368369
370+ if (concreteExecutionResult.result.exceptionOrNull() is UtMockAssumptionViolatedException ) {
371+ logger.debug { " Generated test case by fuzzer violates the UtMock assumption" }
372+ return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
373+ }
374+
369375 val coveredInstructions = concreteExecutionResult.coverage.coveredInstructions
370376 var trieNode: Trie .Node <Instruction >? = null
371377 if (coveredInstructions.isNotEmpty()) {
You can’t perform that action at this time.
0 commit comments