Skip to content

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

Open
@alisevych

Description

@alisevych

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

Metadata

Metadata

Assignees

Labels

comp-fuzzingIssue is related to the fuzzingctg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions