testImplementation ("org.mockito:mockito-inline")
3.4.0 이상 버전의 mockito-inline 의존성을 추가한다.
@ExtendWith(MockitoExtension.class)
class StaticTest {
private MockedStatic<ObjectMapperUtils> objectMapperUtils;
@BeforeEach
void beforeEach() {
objectMapperUtils = mockStatic(ObjectMapperUtils.class);
}
@AfterEach
void afterEach() {
objectMapperUtils.close();
}
@Test
void test() {
// mocking
given(ObjectMapperUtils.readString(any(), eq(UpdatePropertyStatusMessage.class))).willReturn(updatePropertyStatusMessage);
}