UTBotJava
UTBotJava copied to clipboard
Fuzzing generates a test that relies on static field value
Description
Static field value possible changes is not considered
To Reproduce
- Install -IU- UnitTestBot pluginin IntelliJ IDEA Ultimate 2023.2
- Open
utbotproject - Generate and Run tests for
DoubleStreamExamplewith default settings - Run
testPeekExampleReturnsZerogenerated by Fuzzing forpeekExample
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