In Mockito we can mock a method, but I'm wondering is it possible to use a different instance altogether?
More especially in my code, I Autowired
a Clock
as a private field and while testing I want to just use Clock.systemDefaultZone()
. I don't want to mock a specific method of it.
The following is my unit test class:
@RunWith(MockitoJUnitRunner.class)
@EnableAutoConfiguration
@SpringBootTest(classes = {Application.class})
@ActiveProfiles(profiles = {"test"})
public class FooTest extends TestCase {
@Mock
private Clock clock;
}