My tests just repeats the code. For method
public void start(Context context) {
context.setA(CONST_A);
context.setB(CONST_B);
...
}
I wrote test using Mockito
@Test
public void testStart() throws Exception {
Context mockContext = mock(Context.class);
action.start(mockContext);
verify(mockAction).setA(Action.CONST_A);
verify(mockAction).setB(Action.CONST_B);
...
}
Or for
public void act() {
state.act();
}
test
@Test
public void testAct() throws Exception {
State mockState = mock(State.class);
context.setState(mockState);
context.act();
verify(mockState).act();
}
Are such tests useful? Such methods need to be tested and how to test them?
Aucun commentaire:
Enregistrer un commentaire