Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Bad coverage for simple example with loop #2304

Open
Assignees
Labels
comp-symbolic-engineIssue is related to the symbolic execution engine ctg-bugIssue is a bug lang-javaIssue is related to Java support
@tochilinak

Description

Description

Bad example for UTBot symbolic execution engine.

To Reproduce

Steps to reproduce the behavior:

  1. Create project in IntelliJ Idea with the following code:
public class Main {
 int func(int x, int y, int z) {
 assert (y == 0);
 while (y < 10000)
 y += 1;
 if (x == y || z == y)
 return 1;
 return 2;
 }
}
  1. Use plugin to generate tests (with and without fuzzing).

Expected behavior

All lines were covered by generated tests.

Actual behavior

No tests with return value 1 were generated.

Visual proofs (screenshots, logs, images)

Tests generated with 100% symbolic execution:

public final class MainTest {
 ///region Test suites for executable com.company.Main.func
 ///region SYMBOLIC EXECUTION: EXPLICITLY THROWN UNCHECKED EXCEPTIONS for method func(int, int, int)
 /**
 * @utbot.classUnderTest {@link Main}
 * @utbot.methodUnderTest {@link Main#func(int, int, int)}
 * @utbot.executesCondition {@code (assert (y == 0);): True}
 * @utbot.executesCondition {@code (assert (y == 0);): True}
 * @utbot.throwsException {@link AssertionError} in: assert (y == 0);
 */
 @Test
 @DisplayName("func: assert (y == 0) -> ThrowAssertionError")
 public void testFunc_ThrowAssertionError() {
 Main main = new Main();
 
 /* This test fails because method [com.company.Main.func] produces [java.lang.AssertionError]
 com.company.Main.func(Main.java:5) */
 main.func(-255, -255, -255);
 }
 ///endregion
 ///endregion
}

Tests generated with 5% fuzzing:

public final class MainTest {
 ///region Test suites for executable com.company.Main.func
 ///region SYMBOLIC EXECUTION: EXPLICITLY THROWN UNCHECKED EXCEPTIONS for method func(int, int, int)
 /**
 * @utbot.classUnderTest {@link Main}
 * @utbot.methodUnderTest {@link Main#func(int, int, int)}
 * @utbot.executesCondition {@code (assert (y == 0);): True}
 * @utbot.executesCondition {@code (assert (y == 0);): True}
 * @utbot.throwsException {@link AssertionError} in: assert (y == 0);
 */
 @Test
 @DisplayName("func: assert (y == 0) -> ThrowAssertionError")
 public void testFunc_ThrowAssertionError() {
 Main main = new Main();
 
 /* This test fails because method [com.company.Main.func] produces [java.lang.AssertionError]
 com.company.Main.func(Main.java:5) */
 main.func(-255, -255, -255);
 }
 ///endregion
 ///region OTHER: SUCCESSFUL EXECUTIONS for method func(int, int, int)
 @Test
 public void testFunc1() {
 Main main = new Main();
 int actual = main.func(0, 0, 0);
 assertEquals(2, actual);
 }
 ///endregion
 ///endregion
}

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution engine ctg-bugIssue is a bug lang-javaIssue is related to Java support

Type

No type

Projects

Status

In Progress

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /