Protocol buffer classes are marked final
, presumably for efficiency; however, this makes them quite difficult to test with -- Mockito can't mock/spy on final classes. I've tried using PowerMockito
with no success: I get a ClassFormatError
when preparing the final
class for the test.
My solution up until now is to create mockable adapter interfaces, but I'm hoping there's a less laborious approach.
JMockit can handle final
and static
. Just pay attention to how to set it up as it requires the -javaagent JVM parameter, or classpath tweaks, or extra annotations to be able to mock final
and static
stuffs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With