0

As mentioned on some articles like Simplifying Junit, Mockito And PowerMock, I cannot use PowerMock in JUnit5.

As I cannot downgrade my JUnit version to 4 and need to stick with JUnit5, how can I use PowerMock in JUnit5 to test static methods? Or if it is not possible, what should I use? I tried MockStatic, but I am not sure if it is a proper way to test static method. What would you suggest?

  • 1
    It looks like you can use mockito v3.4.0 https://stackoverflow.com/a/63920995/1479895 – Anton Belev Mar 08 '22 at 17:18
  • Thanks, ı will look at. Is there any annotation for the test class except from default one `@RunWith(MockitoJUnitRunner.class)` ? –  Mar 08 '22 at 17:21
  • @AntonBelev The second question is that: Should I call my service method that I am testing inside `try` block? –  Mar 08 '22 at 17:25
  • In any case I get "there were zero interactions with this mock" error. Any idea? –  Mar 08 '22 at 17:38

0 Answers0