on-internet
← Community

How to use MockedStatic verify on static methods?

Stack Overflow ·

I have the following mocks for 2 different static method; UnitConversion.isCompatible() and Logging.error() that are called in my service method. Here is my test method: myService.demoMethod(); try (MockedStatic<UnitConversion> unitConversion= mockStatic(UnitConversion.class)) { unitConversion.verify(never(), () -> UnitConversion.isCompatible(any())); UnitConversion.isUnitsCompatible(any()); } try (MockedStatic<Logging> logging = mockStatic(Logging.class)) { logging.verify(times(1), () -> Logging.error(any())); Logging.error(any(); } The first method is never called while the second one is cal

Comments

Sign in or sign up to comment and upvote.

No comments yet.