I am trying to write a test for this class called Receiver:
public void get(People person) { if(null != person) { LOG.info("Person with ID " + person.getId() + " received"); processor.process(person); }else{ LOG.info("Person not received abort!"); } }
Here is the test:
@Test public void testReceivePerson(){ context.checking(new Expectations() {{ receiver.get(person); atLeast(1).of(person).getId(); will(returnValue(String.class)); }}); }
Note : a receiver is an instance of the Receiver class (the real one is not a mock), a processor is an instance of the Processor class (real not mock) that processes a person (a model of an object of the People class). GetId is a String not int method that is not an error.
Test fails: unexpected call to person.getId ()
I am using jMock, any help would be appreciated. As I understand it, when I call this get method to execute it correctly, I need to make fun of person.getId() , and I have been spinning around in circles for a while, any help would be appreciated.
java unit-testing junit testing jmock
London
source share