Hello everyone, I would like to discuss moving away from mocking frameworks like PowerMock, EasyMock etc., replacing them with Mockito where feasible. [1] [2]
Rationale: The Apache Maven project is going to do the same switch, because Mockito seems to have superior support for the module system introduced in Java 9. It was also the first to have a module-compatible release. PowerMock cannot be used anymore because of illegal reflection access. In Java 9 and above, opening final methods or classes is not allowed anymore. Instead, better class design is needed anyway. Some tests are already failing on JDK11, like the EnvironmentLoaderServiceTest when used in conjunction with JDK11 (I use openj9 11.0-6 from adoptopenjdk.net), However, this does not seem to be the case in our Jenkins with a hotspot JVM. [3] Benefits: If new tests were written in Mockito only, it is easier to navigate the code. Replacing PowerMock with Mockito will have the benefit of forced good class design and not breaking the tests in future JDK releases. Additional thoughts: I would like to add a build job with an openj9 JDK (both Java 8 and 11). Non-Goals: Switching the baseline JDK requirement to 9 or even 11. Rewrite every test. I am looking forward to hearing your opinions on this topic! Ben [1] https://github.com/apache/maven-site/pull/158/files [2] https://lists.apache.org/thread.html/r5fd75d1a769d1f8b25f1342789d253cda362d675a9825f6d4bf664f5%40%3Cdev.maven.apache.org%3E [3] https://builds.apache.org/view/S-Z/view/Shiro/job/Shiro-master-jdk11/
