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
HashMap with Enum as key - test generation fails #436
Test generation fails for a method with HashMap using Enum as key.
To Reproduce
Steps to reproduce the behavior:
IntelliJ IDEA with UTBotJava plugin installed
A project with JDK 8/11 is opened
Add the following class:
public class MapWithEnum {
public void createMapWithEnum() {
Map<WorkDays, Integer> map = new HashMap<>();
map.put(WorkDays.Monday, 112);
map.put(WorkDays.Tuesday, 354);
map.put(WorkDays.Friday, 567);
map.remove(WorkDays.Tuesday);
}
public enum WorkDays {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday
}
}
Run Generating tests with UTBot... for this class
Expected behavior
Tests are supposed to be generated.
Actual behavior
"Failed to generate unit tests for class MapWithEnum" error popup is shown in IDEA.
It is shown immediately after test generation is started.
Map.remove() method is crucial for the issue - without it generation passes.
Visual proofs (screenshots, logs, images)
Environment
Windows 10 Pro
IntelliJ IDEA 2022.1.3
checked on JDK 8 and 11, Gradle, Maven projects - same error
Additional context
Adding some input parameters to the method helps - fuzzer is generating tests.
Map.remove() method is crucial for the issue - without it generation passes.
Activity
dtim commentedon Jul 6, 2022
Related to #230, #414
dtim commentedon Jul 28, 2022
It seems that the problem is not enum-specific. The following example does not work as well:
* tests to investigate the issue #436
* tests to investigate the issue #436
CaelmBleidd commentedon Oct 19, 2022
Looks like it doesn't work when key and value have different types. Following examples doesn't work as well: