mercredi 30 septembre 2015

EasyMock: call order on mocks created with @Mock

Is there any way to verify methods call order between mocks if they are created with @Mock annotation?

As described in documentation it can be done with a mock control. But EasyMockRule does not expose control object. I have looked at EasyMockSupport implementation, but have not found way to force it to use one control for all injected mocks. :(

public class Test extends EasyMockSupport {

 @Rule
 public EasyMockRule mocks = new EasyMockRule(this);

 @Mock
 private SomeClass first;

 @Mock
 private OtherClass second;

 @TestSubject
 private UnderTest subject = new UnderTest ();

 @Test
 public void test() {
   expect(first.call());
   expect(second.call());
   ....
   //Verify that calls were in order first.call(), second.call()
 }
}

Aucun commentaire:

Enregistrer un commentaire