New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix reflective access in test classes #3322
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3322 +/- ##
============================================
+ Coverage 21.96% 21.96% +<.01%
- Complexity 5883 5884 +1
============================================
Files 834 834
Lines 72443 72443
Branches 11659 11659
============================================
+ Hits 15913 15914 +1
+ Misses 54434 54433 -1
Partials 2096 2096
Continue to review full report at Codecov.
|
@RoiEXLab Did you happen to find a reference that suggests Mockito no longer supports spying on JDK types (or simply types in a different module) in Java 9? This issue seems related, and it's been marked as a bug. I added an MCVE to see if the Mockito maintainers acknowledge whether what we're doing is supported or not. |
@ssoloff I found this issue as well, but it has a slightly different error message. |
@RoiEXLab Are you talking about the field it refers to at the end of the message? That is,
vs.
I believe that difference is simply because two different types are being spied upon, and thus Mockito encounters a different field on which it attempts to reflectively access.
I suspect this issue will affect any attempt to spy on a type in a different module, which means, when TripleA is modularized, you may run into the same issue again (there are currently 17 spies of TripleA types). Regardless, two of the five changes from spies to mocks in this PR are perfectly fine and a good clean up because those instances (currently) do not rely on any behavior of the concrete implementation. |
Yes, that's what I'm thinking as well.
Possible, but if we actually do this would indicate a serious design issue. Tests are technically in the same package (the same module as well if we'd introduce them) as their test subjects. |
This seems to fix the remaining reflective access issues (that are our fault) as reported in #2796