UTBotJava icon indicating copy to clipboard operation
UTBotJava copied to clipboard

Fuzzing generates a test that relies on static field value

Open alisevych opened this issue 2 years ago • 0 comments

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 avatar Oct 05 '23 10:10 alisevych