I have a java class which i test in groovy/spock. The java class has a final field:
private static final log = Logger.getLogger(...)
I want to test if a method uses this logger, preferably using a mock. The problem is that this field is final so I can't just set it. I know that there are workarounds like:
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
but these are awful hacks. Is there a more groovy way to do this?