Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuzzing generates a test that relies on static field value #2649

Open
alisevych opened this issue Oct 5, 2023 · 0 comments
Open

Fuzzing generates a test that relies on static field value #2649

alisevych opened this issue Oct 5, 2023 · 0 comments
Assignees
Labels
comp-fuzzing Issue is related to the fuzzing ctg-bug Issue is a bug

Comments

@alisevych
Copy link
Member

Description

Static field value possible changes is not considered

To Reproduce

  1. Install -IU- UnitTestBot pluginin IntelliJ IDEA Ultimate 2023.2
  2. Open utbot project
  3. Generate and Run tests for DoubleStreamExample with default settings
  4. Run testPeekExampleReturnsZero generated by Fuzzing for peekExample

Expected behavior

Tests should pass when run separately or altogether.

Actual behavior

testPeekExampleReturnsZero passes when run standalone and fails when run in test class.

Screenshots, logs

    ///region Test suites for executable org.utbot.examples.stream.DoubleStreamExample.peekExample

    ///region FUZZER: SUCCESSFUL EXECUTIONS for method peekExample(java.util.List)

    /**
     * @utbot.classUnderTest {@link DoubleStreamExample}
     * @utbot.methodUnderTest {@link DoubleStreamExample#peekExample(java.util.List)}
     */
    @Test
    @DisplayName("peekExample: list = collection -> return 0")
    public void testPeekExampleReturnsZero() {
        DoubleStreamExample doubleStreamExample = new DoubleStreamExample();
        LinkedList list = new LinkedList();
        list.add(Short.MIN_VALUE);
        list.add((short) -1);
        list.add(Short.MAX_VALUE);

        int actual = doubleStreamExample.peekExample(list);

        assertEquals(0, actual);
    }
    ///endregion

    ///endregion

Environment

IntelliJ IDEA version - Ultimate 2023.2
Project - Gradle
JDK - 17

Additional context

peekExample returns static field beforeStaticValue value that is changed by another test

@alisevych alisevych added ctg-bug Issue is a bug comp-fuzzing Issue is related to the fuzzing labels Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-fuzzing Issue is related to the fuzzing ctg-bug Issue is a bug
Projects
Status: Todo
Development

No branches or pull requests

2 participants