I need to mock a static class and bind it during the service start up time. Following https://asolntsev.github.io/en/2020/07/11/mockito-static-methods/, I set up mockedstatic for the class and expectation. I want to know how I can returned the mocked class T not MockedStatic?
public static MyClass mockClass() {
try (MockedStatic<MyClass> myClass = Mockito.mockStatic(MyClass.class)) {
myClass.when(() -> MyClass.getMetho(Mockito.any()))
.thenReturn("abc");
return myClass;
}}
return myClass doesn't work. How can I strip MyClass from MockedStatic?
Aucun commentaire:
Enregistrer un commentaire