<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.12.4</version>
<scope>test</scope>
</dependency>
import static org.mockito.Mockito.*;
public class ExampleTest {
@Test
public void testExample() {
Example example = mock(Example.class);
when(example.method()).thenReturn("mocked value");
String result = example.method();
verify(example, times(1)).method();
assertEquals("mocked value", result);
}
}