mockito for java 17

following up https://lwpro2.wordpress.com/2023/05/14/java-8-to-java-17-migration-for-a-large-monolithic/, there are further bugs to fix with the existing implementation with Mockito (somehow the existing codebase used mockito, together with easyMock, PowerMock as well).

The workable versions are :

in addition,

  1. switching from mockito 1 to 2, it now stops matching null with any. so the solution is to wrap it with nullable.

2. another breaking change is, mockito 2 doesn’t match array with any. the solution is to cast with any(Object[].class)

3. Mockito anyCollection().toArray() is no longer matching with array

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s