You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fuzzer ignores generics of class StringMap extends HashMap<String, String> #2571
No passing tests are generated, one of the tests fails to compile with the following error: "incompatible types: Object cannot be converted to StringstringMap.put(object, object1);".
Visual proofs (screenshots, logs, images)
/** * @utbot.classUnderTest {@link StringMap} * @utbot.methodUnderTest {@link StringMap#getAnyString()} */@Test@DisplayName("getAnyString: -> throw ClassCastException")
publicvoidtestGetAnyStringThrowsCCE() {
StringMapstringMap = newStringMap();
Objectobject = newObject();
Objectobject1 = newObject();
stringMap.put(object, object1);
/* This test fails because method [org.example.StringMap.getAnyString] produces [java.lang.ClassCastException: class java.lang.Object cannot be cast to class java.lang.String (java.lang.Object and java.lang.String are in module java.base of loader 'bootstrap')] org.example.StringMap.getAnyString(StringMap.java:7) */stringMap.getAnyString();
}
Most likely, it won't compile because of an error with code gen part that try to cast String to Object before it puts the string into map. I've wrote about this problem in PR: #2610. Maybe @EgorkaKulikov or @IlyaMuravjov could take a look at this problem?
Activity
alisevych commentedon Sep 20, 2023
A very similar issue is reproducing on
spring-petclinicproject with PetController tests.Is it the same?
Tests are not compiling.
ModelMap is spring framework type extending LinkedHashMap<String, Object>
Fuzzer is generating Objects as keys to fill it.
And issue - #2595 - is present too.
IlyaMuravjov commentedon Sep 20, 2023
Yes, it's the same issue.
#2595 only reproduces on UtBot version from #2583 and I hope it will be fixed before #2583 is merged.
alisevych commentedon Sep 25, 2023
@Markoutte
The issue is reproducing with the PR merged.
I've taken IU plugin from here: https://github.com/UnitTestBot/UTBotJava/actions/runs/6257133258
The following test is generated for
spring-petclinicPetControllerclassprocessCreationFormmethod:model.put...is not compilingCan you please check?
Markoutte commentedon Sep 25, 2023
@alisevych Looks like the problem here:
Most likely, it won't compile because of an error with code gen part that try to cast String to Object before it puts the string into map. I've wrote about this problem in PR: #2610. Maybe @EgorkaKulikov or @IlyaMuravjov could take a look at this problem?