Closed aoudiamoncef closed 2 years ago
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.
Thanks for contributing and raising this pull request @aoudiamoncef ! that's very helpful. I fear that there might be a substantial amount of users still using older Mockito versions. Since Mockito is used extensively by test templates, I think the best approach would be to add a configuration option for selecting the preferred Mockito version. So the template code will use the right Mockito method that is relevant for the Mockito version configured by the user.
@aoudiamoncef , I've pushed a fix for this issue in https://github.com/wrdv/testme-idea/pull/14. plugin update is available for installation from IDEA - v5.1.0. I took a different approach eventually - generating openMocks() instead of initMocks() in case mockito-core lib version in target test module classpath is at least v3.4. Hope this works in practice for all use cases. Sorry it took so long to handle this issue. Thanks for reporting this. closing this issue
Hi, I'm just wondering if merely replacing it with openMocks
is enough since openMocks
is Autoclosable as opposed to initMocks. You'll also need to close it in teardown phase.
@saranshbansal good point. I think on most use cases, there won't be any harm if the mocks would not be closed. So I'm guessing most developers would find it adds unnecessary verbosity. However, it would be nice to provide such an option. perhaps as an intention or code generation option.
In Mockito 2 there is a MockitoAnnotations.initMock() method, which is deprecated and replaced with MockitoAnnotations.openMocks() in Mockito 3.