Mocking static methods (and constructors) using Mockito 3.5.0+

Since version 3.4.0, Mockito allows us to mock static methods, so you do not need to add powermock as dependency for most of your necessities. I will not discuss why we should avoid static methods or helper class with static methods, as several articles do it quite well (1, 2, 3, etc..), we need to deal with static methods in the real world of development and mockito helps us to create unit tests when these static methods are involved....

December 30, 2020 · 4 min · Tomás Dias Almeida