-
Notifications
You must be signed in to change notification settings - Fork 45
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
TreeSet tests contain too much reflection with system classes #1282
Comments
Additional context Without changes from PR - #1265 - the reflection in test class is a bit different. But too much reflection is also present. ///region Test suites for executable org.utbot.examples.collections.CollectionExample.testTreeSetWithComparable
///region
@Test
public void testTestTreeSetWithComparable1() {
CollectionExample collectionExample = new CollectionExample();
/* This test fails because method [org.utbot.examples.collections.CollectionExample.testTreeSetWithComparable] produces [java.lang.NullPointerException]
org.utbot.examples.collections.CollectionExample.testTreeSetWithComparable(CollectionExample.java:124) */
collectionExample.testTreeSetWithComparable(null);
}
@Test
public void testTestTreeSetWithComparable2() throws Exception {
CollectionExample collectionExample = new CollectionExample();
ConcurrentSkipListSet set = ((ConcurrentSkipListSet) createInstance("java.util.concurrent.ConcurrentSkipListSet"));
ConcurrentSkipListMap concurrentSkipListMap = ((ConcurrentSkipListMap) createInstance("java.util.concurrent.ConcurrentSkipListMap"));
setField(concurrentSkipListMap, "java.util.concurrent.ConcurrentSkipListMap", "head", null);
setField(set, "java.util.concurrent.ConcurrentSkipListSet", "m", concurrentSkipListMap);
boolean actual = collectionExample.testTreeSetWithComparable(set);
assertFalse(actual);
}
@Test
public void testTestTreeSetWithComparable3() throws Exception {
CollectionExample collectionExample = new CollectionExample();
ConcurrentSkipListSet set = ((ConcurrentSkipListSet) createInstance("java.util.concurrent.ConcurrentSkipListSet"));
ConcurrentSkipListMap concurrentSkipListMap = ((ConcurrentSkipListMap) createInstance("java.util.concurrent.ConcurrentSkipListMap"));
Object index = createInstance("java.util.concurrent.ConcurrentSkipListMap$Index");
Object node = createInstance("java.util.concurrent.ConcurrentSkipListMap$Node");
setField(index, "java.util.concurrent.ConcurrentSkipListMap$Index", "node", node);
setField(concurrentSkipListMap, "java.util.concurrent.ConcurrentSkipListMap", "head", index);
LongAdder longAdder = ((LongAdder) createInstance("java.util.concurrent.atomic.LongAdder"));
Object[] cellArray = createArray("java.util.concurrent.atomic.Striped64$Cell", 0);
setField(longAdder, "java.util.concurrent.atomic.Striped64", "cells", cellArray);
setField(longAdder, "java.util.concurrent.atomic.Striped64", "base", 2147483647L);
setField(concurrentSkipListMap, "java.util.concurrent.ConcurrentSkipListMap", "adder", longAdder);
setField(set, "java.util.concurrent.ConcurrentSkipListSet", "m", concurrentSkipListMap);
boolean actual = collectionExample.testTreeSetWithComparable(set);
assertTrue(actual);
}
///endregion
///endregion
///region Test suites for executable org.utbot.examples.collections.CollectionExample.testTreeSetWithoutComparable
///region
@Test
public void testTestTreeSetWithoutComparable1() {
CollectionExample collectionExample = new CollectionExample();
/* This test fails because method [org.utbot.examples.collections.CollectionExample.testTreeSetWithoutComparable] produces [java.lang.NullPointerException]
org.utbot.examples.collections.CollectionExample.testTreeSetWithoutComparable(CollectionExample.java:114) */
collectionExample.testTreeSetWithoutComparable(null);
}
@Test
public void testTestTreeSetWithoutComparable2() throws Exception {
CollectionExample collectionExample = new CollectionExample();
ConcurrentSkipListSet set = ((ConcurrentSkipListSet) createInstance("java.util.concurrent.ConcurrentSkipListSet"));
ConcurrentSkipListMap concurrentSkipListMap = ((ConcurrentSkipListMap) createInstance("java.util.concurrent.ConcurrentSkipListMap"));
setField(concurrentSkipListMap, "java.util.concurrent.ConcurrentSkipListMap", "head", null);
setField(set, "java.util.concurrent.ConcurrentSkipListSet", "m", concurrentSkipListMap);
boolean actual = collectionExample.testTreeSetWithoutComparable(set);
assertFalse(actual);
}
@Test
public void testTestTreeSetWithoutComparable3() throws Exception {
CollectionExample collectionExample = new CollectionExample();
ConcurrentSkipListSet set = ((ConcurrentSkipListSet) createInstance("java.util.concurrent.ConcurrentSkipListSet"));
ConcurrentSkipListMap concurrentSkipListMap = ((ConcurrentSkipListMap) createInstance("java.util.concurrent.ConcurrentSkipListMap"));
Object index = createInstance("java.util.concurrent.ConcurrentSkipListMap$Index");
Object node = createInstance("java.util.concurrent.ConcurrentSkipListMap$Node");
setField(index, "java.util.concurrent.ConcurrentSkipListMap$Index", "node", node);
setField(concurrentSkipListMap, "java.util.concurrent.ConcurrentSkipListMap", "head", index);
LongAdder longAdder = ((LongAdder) createInstance("java.util.concurrent.atomic.LongAdder"));
Object[] cellArray = createArray("java.util.concurrent.atomic.Striped64$Cell", 0);
setField(longAdder, "java.util.concurrent.atomic.Striped64", "cells", cellArray);
setField(longAdder, "java.util.concurrent.atomic.Striped64", "base", 2147483647L);
setField(concurrentSkipListMap, "java.util.concurrent.ConcurrentSkipListMap", "adder", longAdder);
setField(set, "java.util.concurrent.ConcurrentSkipListSet", "m", concurrentSkipListMap);
boolean actual = collectionExample.testTreeSetWithoutComparable(set);
assertTrue(actual);
}
///endregion
///endregion |
The reason for it -- we don't have a wrapper for |
Description
Symbolic execution for examples using TreeSet produces tests with too complex reflection with system classes.
To Reproduce
Mock everything outside package
Expected behavior
Generated tests are supposed to instantiate objects regularly.
Actual behavior
Generated tests contain too much reflection with system classes
Visual proofs (screenshots, logs, images)
Environment
Windows 10 Pro
IntelliJ IDEA 2022.1.4 (JBR 11)
UTBotJava project (Gradle , JDK 11)
Additional context
Code taken from PR - #988
The text was updated successfully, but these errors were encountered: