You can use PowerMockito
Second second = Mockito.mock(Second.class);
whenNew(Second.class).withNoArguments().thenReturn(second);
But re-factoring is better decision.
More Related Contents:
- Mocking static methods with Mockito
- How to mock void methods with Mockito
- Difference between @Mock and @InjectMocks
- Mockito – difference between doReturn() and when()
- Using Mockito to test abstract classes
- Test class with a new() call in it with Mockito
- Final method mocking
- How to use Mockito with JUnit5
- Mockito : how to verify method was called on an object created within a method?
- How to tell a Mockito mock object to return something different the next time it is called?
- Mockito: InvalidUseOfMatchersException
- How to use ArgumentCaptor for stubbing?
- How to mock new Date() in java using Mockito
- Mockito, JUnit and Spring
- Mockito – @Spy vs @Mock
- Mockito verify order / sequence of method calls
- mock or stub for chained call
- How to verify that a specific method was not called using Mockito?
- Mock final class with Mockito 2
- Why are my mocked methods not calld when executing a unit test?
- Forming Mockito “grammars”
- What’s the difference between Mockito Matchers isA, any, eq, and same?
- How to mock RestTemplate in Java Spring?
- Java verify void method calls n times with Mockito
- Can Mockito verify parameters based on their values at the time of method call?
- Why are my mocked methods not called when executing a unit test?
- How to mock a builder with mockito
- Is it possible to use Mockito in Kotlin?
- junit & java : testing non-public methods [duplicate]
- Eclipse classpath entries only used for tests