I'm using @MethodSource annotation on my Junit test case in order to receive from another method a Map<String, Object>.
Seems that @MethodSource cannot support "Map" object.
This is the error I received: org.junit.platform.commons.PreconditionViolationException: Cannot convert instance of java.util.HashMap into a Stream: {1=Obj1, 2=Obj2}
Do you know if there is a way to receive back a "Map" object like in this example?
@ParameterizedTest
@MethodSource("hashMapProvider")
void testMyMapObj(Map<String, Object> argument) {
assertNotNull(argument);
Object obj1 = argument.get("1");
}
static Map<String, Object> hashMapProvider() {
Map<String, Object> map = new HashMap<>();
map.put("1", "Obj1");
map.put("2", "Obj2");
return map;
}