Mockito - weird package scope class inheritance issue

后端 未结 1 1529
一个人的身影
一个人的身影 2021-01-20 06:55

Found very interesting issue and after debugging found the scenario to reproduce it.

So, if I have a class with package scope B that has some public method and publi

相关标签:
1条回答
  • 2021-01-20 07:22

    edit

    Latest mockito 2.x beta use now ByteBuddy which isn't affected by this issue. There may be some API ajustements left but it is pretty much both working and functional. Also there will be breaking compatibility with existing mockito matchers. If that's ok for the project that would be great to have feedback on the API while mockito 2 is in beta.

    original

    There's a known issue when the mocked class have a non public parent. The method cannot be stubbed. See issue 212.

    The issue is that bridge methods are generated by the compiler in order to access the method from the parent, however this confuses bytecode tools like CGLIB. Unless you can fix CGLIB, there's no real solution.

    Sorry you have to workaround this in a different way :/

    0 讨论(0)
提交回复
热议问题