Hi,
I'm using JMock for testing with JUnit. Everything works fine, and I've defined number of test,
but now I have one wierd problem when testing Struts actions. So I have like this in my testing class :
public class MyTestingClass {
PersonService service = context.mock(PersonService.class);
Person person = new Person();
// fill person object
@Test
public void testMethod() throws Exception {
context.checking(new Expectations() {{
one (service).findByUsername(person.getUsername()); will(returnValue(person));
}});
}
// set service
// run action
}
and when this line of code is called in my class, like this:
public MainClass {
PersonService
service;
get/set methods
public method() {
person = service.findByUsername(username);
}
}
I get this exception:
"unexpected invocation: service.findByUsername(username);
It seems like that JMock doesn't recognize this method, but I don't get any syntax errors. What is the problem here ?
--
Thx, Milan