-1

I need to test sorting class which takes a array of certain interface type. The interface only has one function which only compare an object and return some int value. I am trying to use easymock to test it with jUnit. I am stuck with two problems. First, I need to assign some value to the each mock object that I created for the given interface.

mock[0] = EasyMock.createMock(CompareValue.class);

How can I assign some value to mock[0]? The interface CompareValue only has following method:

int compareVal(Object obj);

the object is going to be a CompareValue type in the sorting class

Second, I only have static void method in the class which takes a list and modifies it but dont return anything. I am not suppose to change any code in interface or class.I dont know how to retrieve that modified list to check if it has been sorted correctly.

Ramy
  • 305
  • 1
  • 5
  • 10

1 Answers1

1

Override the getter instead of assigning a value to the mock.

expect(mock[0].getValue()).andRetun(yourValue);
Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72