0

I am writing a unit test around void function. Inside that I call another function.
I want to test that this function should be called only once. If it is getting called 0 or 2 times, it should fail.

I have tried using followings.But even if I remove the function call from code, test does not fail.

EasyMock.expectLastCall().once();
EasyMock.expectLastCall().atLeastOnce();
shantanu
  • 1,748
  • 3
  • 19
  • 34

1 Answers1

0

this should work: (but you could also omit EasyMock.expectLastCall().once())

    I m = EasyMock.createMock(I.class);
    m.meth();
    EasyMock.expectLastCall().once();
    EasyMock.replay(m);


    m.meth();
    m.meth(); //fails


    EasyMock.verify(m);
wrm
  • 1,898
  • 13
  • 24