diff --git a/gradle.properties b/gradle.properties index 5cf79d2a49..8dc2f9fdd2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,7 +18,7 @@ junit4PlatformVersion=1.9.0 mockitoVersion=3.5.13 z3Version=4.8.9.1 z3JavaApiVersion=4.8.9 -sootCommitHash=3adf23c3 +sootCommitHash=ed85c59 kotlinVersion=1.7.20 log4j2Version=2.13.3 coroutinesVersion=1.6.3 diff --git a/utbot-framework-test/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt b/utbot-framework-test/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt index b66c17f8b2..461faf48b2 100644 --- a/utbot-framework-test/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt +++ b/utbot-framework-test/src/test/kotlin/org/utbot/examples/exceptions/ExceptionExamplesTest.kt @@ -7,6 +7,7 @@ import org.utbot.tests.infrastructure.isException import org.utbot.framework.plugin.api.CodegenLanguage import org.junit.jupiter.api.Test import org.utbot.testcheckers.eq +import org.utbot.testcheckers.withoutConcrete import org.utbot.tests.infrastructure.CodeGeneration internal class ExceptionExamplesTest : UtValueTestCaseChecker( @@ -106,6 +107,23 @@ internal class ExceptionExamplesTest : UtValueTestCaseChecker( ) } + /** + * Covers [#656](https://github.com/UnitTestBot/UTBotJava/issues/656). + */ + @Test + fun testCatchExceptionAfterOtherPossibleException() { + withoutConcrete { + checkWithException( + ExceptionExamples::catchExceptionAfterOtherPossibleException, + eq(3), + { i, r -> i == -1 && r.isException() }, + { i, r -> i == 0 && r.getOrThrow() == 2 }, + { i, r -> r.getOrThrow() == 1 }, + coverage = atLeast(100) + ) + } + } + /** * Used for path generation check in [org.utbot.engine.Traverser.fullPath] */ diff --git a/utbot-sample/src/main/java/org/utbot/examples/exceptions/ExceptionExamples.java b/utbot-sample/src/main/java/org/utbot/examples/exceptions/ExceptionExamples.java index cf259389fc..5e90050dbd 100644 --- a/utbot-sample/src/main/java/org/utbot/examples/exceptions/ExceptionExamples.java +++ b/utbot-sample/src/main/java/org/utbot/examples/exceptions/ExceptionExamples.java @@ -86,6 +86,18 @@ public int catchDeepNestedThrow(int i) { } } + public int catchExceptionAfterOtherPossibleException(int i) { + int x = 15; + x /= i + 1; + + try { + x /= i; + } catch (RuntimeException e) { + return 2; + } + return 1; + } + public IllegalArgumentException createException() { return new IllegalArgumentException("Here we are: " + Math.sqrt(10)); }