Closed
Description
Description
Even though #1635 is fixed, still when private class extends Collection then Fuzzer generates test with usage of reflection.
To Reproduce
Steps to reproduce the behavior:
import java.util.ArrayList;
public class PrivateTest {
public void foo(Call call) {
}
private static class Call extends ArrayList {
public Call() {
}
}
}
- Set Fuzzer to to 100%
- Generate test for code above
Expected behavior
No tests are generated
Actual behavior
Fuzzer generates test:
///region FUZZER: SUCCESSFUL EXECUTIONS for method foo(com.google.common.primitives.PrivateTest.Call)
/**
* @utbot.classUnderTest {@link PrivateTest}
* @utbot.methodUnderTest {@link PrivateTest#foo(PrivateTest.Call)}
*/
@Test
public void testFoo1() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
PrivateTest privateTest = new PrivateTest();
Class callClazz = Class.forName("com.google.common.primitives.PrivateTest$Call");
Constructor callConstructor = callClazz.getDeclaredConstructor();
callConstructor.setAccessible(true);
Object[] callConstructorArguments = new Object[0];
Object call = callConstructor.newInstance(callConstructorArguments);
Class privateTestClazz = Class.forName("com.google.common.primitives.PrivateTest");
Method fooMethod = privateTestClazz.getDeclaredMethod("foo", callClazz);
fooMethod.setAccessible(true);
Object[] fooMethodArguments = new Object[1];
fooMethodArguments[0] = call;
fooMethod.invoke(privateTest, fooMethodArguments);
}
Metadata
Metadata
Assignees
Type
Projects
Status
Done