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 1
1
package org .utbot .api .mock ;
2
2
3
+ import org .utbot .api .exception .UtMockAssumptionViolatedException ;
4
+
3
5
public class UtMock {
4
6
public static <T > T makeSymbolic () {
5
7
return makeSymbolic (false );
@@ -14,14 +16,14 @@ public static <T> T makeSymbolic(boolean isNullable) {
14
16
public static void assume (boolean predicate ) {
15
17
// to use compilers checks, i.e. for possible NPE
16
18
if (!predicate ) {
17
- throw new RuntimeException ();
19
+ throw new UtMockAssumptionViolatedException ();
18
20
}
19
21
}
20
22
21
23
@ SuppressWarnings ("unused" )
22
24
public static void assumeOrExecuteConcretely (boolean predicate ) {
23
25
// 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
25
27
}
26
28
27
29
@ SuppressWarnings ("unused" )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import mu.KotlinLogging
7
7
import org.utbot.analytics.EngineAnalyticsContext
8
8
import org.utbot.analytics.FeatureProcessor
9
9
import org.utbot.analytics.Predictors
10
+ import org.utbot.api.exception.UtMockAssumptionViolatedException
10
11
import org.utbot.common.bracket
11
12
import org.utbot.common.debug
12
13
import org.utbot.engine.MockStrategy.NO_MOCKS
@@ -366,6 +367,11 @@ class UtBotSymbolicEngine(
366
367
// in case an exception occurred from the concrete execution
367
368
concreteExecutionResult ? : return @runJavaFuzzing BaseFeedback (result = Trie .emptyNode(), control = Control .PASS )
368
369
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
+
369
375
val coveredInstructions = concreteExecutionResult.coverage.coveredInstructions
370
376
var trieNode: Trie .Node <Instruction >? = null
371
377
if (coveredInstructions.isNotEmpty()) {
You can’t perform that action at this time.
0 commit comments