Description
When there're only one implementation of some interface with generic type fuzzing choose this implementation even it is not suitable for a method.
To Reproduce
- Use only fuzzer
- Generate test for method
test.
public class Implementations {
public interface A<T> {
T getValue();
}
public static class AImpl implements A<String> {
private final String value;
public AImpl(String value) {
this.value = value;
}
@Override
public String getValue() {
return value;
}
}
public static int test(A<Integer> value) {
if (value.getValue() < 0) {
return 0;
}
return value.getValue();
}
}
Expected behavior
The only one method with null is generated, because there're no other options to create this class by fuzzer.
Actual behavior
2 tests are generated: with null and other with AImpl:
@Test
@DisplayName("test: arg_0 = AImpl(String) -> throw ClassCastException")
public void testTestThrowsCCE() {
AImpl aImpl = new AImpl("-3E");
/* This test fails because method [sanity.Implementations.test] produces [java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer]
sanity.Implementations.test(Implementations.java:24) */
Implementations.test(aImpl);
}
This test cannot be compiled.
Additional context
The issue was introduced by 19fc16c
Description
When there're only one implementation of some interface with generic type fuzzing choose this implementation even it is not suitable for a method.
To Reproduce
test.Expected behavior
The only one method with null is generated, because there're no other options to create this class by fuzzer.
Actual behavior
2 tests are generated: with null and other with
AImpl:This test cannot be compiled.
Additional context
The issue was introduced by 19fc16c