Mockito
What is Mockito?
Instead of stub some dummy response using dummy class. Mock class provide all that for us. We can mock any class or interfaces.
Mock:
It will mock the whole class. We have to stub all the methods.
Spy :
* Spy is nothing but it will create the real class. But we can stub any specific method alone. Other methods will work normally.
* We can verify also .
* Mostly will not use. Because it is maintain complex because half is real values half is stub.
* Very old system no other option, will use this spy.
@RunWith(MockitoJunitRunner.class)
This is used to make the class as mockito test class.
@Mock
It is used to mock particular class.
@InjectMock
Injected mock classes into this class.
Instead of stub some dummy response using dummy class. Mock class provide all that for us. We can mock any class or interfaces.
Mock:
It will mock the whole class. We have to stub all the methods.
Spy :
* Spy is nothing but it will create the real class. But we can stub any specific method alone. Other methods will work normally.
* We can verify also .
* Mostly will not use. Because it is maintain complex because half is real values half is stub.
* Very old system no other option, will use this spy.
@RunWith(MockitoJunitRunner.class)
This is used to make the class as mockito test class.
@Mock
It is used to mock particular class.
@InjectMock
Injected mock classes into this class.
Comments
Post a Comment