In the program below, I am trying to use mockito with junit in my test case. But I don't see how Mokito is helping to create objects for my test? I don't see anything special here as it seems as if mokito is instantiating the actually object.
public class TestCase1{
@Mock
MyClass myClass;
public void setup(){
MokitoAnnotations.initMoks(this);
}
public void testAddition(){
when(myClass.add(2,2)).thenReturn(20);
assertEquals(4,myClass.add(2,2));
}
}
Is it mocking an object, the same as injecting(DI) an object? I appreciate your help!
Aucun commentaire:
Enregistrer un commentaire