6

It's easy enough in EasyMock to do:

EasyMock.expect(service.methodCall());

but I noticed that this does not test the order in which I execute the calls, which in a case that I am trying to test is very important. Is there anyway to do this with EasyMock?

starblue
  • 55,348
  • 14
  • 97
  • 151
lottolove
  • 61
  • 1
  • 2

2 Answers2

7

You can use the EasyMock.createStrictMock() for creating a mock thats capable of checking the order of method calls.

http://easymock.org/EasyMock3_0_Documentation.html

(search for "Checking Method Call Order Between Mocks" in the above link for examples).

keshav84
  • 2,291
  • 5
  • 25
  • 34
2

If you need to test the order across different mocked objects, you can use EasyMock.createStrictControl() to create the mocks, run replay() & verify().

This site has some handy sample code: http://www.michaelminella.com/testing/mock-controls-with-easymock.html (archive.org mirror)

mskfisher
  • 3,291
  • 4
  • 35
  • 48
Mark McDonald
  • 7,571
  • 6
  • 46
  • 53