Open adessaigne opened 2 years ago
Here is a dirty hack I've found that works around this issue
public static <T> void setJMockitDefaultValue(Class<T> aClass, T defaultValue) {
requireNonNull(aClass, "The class must be defined");
requireNonNull(defaultValue, "The default value must be defined");
try {
final Field field = DefaultValues.class.getDeclaredField("TYPE_DESC_TO_VALUE_MAP");
field.setAccessible(true);
final Map<String, Object> map = (Map<String, Object>) field.get(null);
map.put(aClass.descriptorString(), defaultValue);
} catch (Exception e) {
throw new RuntimeException("Cannot initialize JMockit properly", e);
}
}
Hello,
In the following environment:
When testing the following code
We have the following exception
It fails because it tries to mock the enum. Is there a way to say "do not try to mock the result, I will provide it to you"? Thank you