-1

I am using easymock to test my class. After writing codes, I find out that every test succeeds even given wrong inputs. From the forums on stack overflow, I have seen that it could be avoided by using the replay method but it even succeeds when I use replay as well. I don't know what I am doing wrong? Could you please look at the code and tell me If I have to do any more things to make test fail ? I think test is not working ..

service = EasyMock.createMock(MyService.class);
menu = EasyMock.createMock(ISPFMenu.class);
menu.setName("name");
menu.setTitle("title");

EasyMock.expect(service.createLinesToParseEasyMock(menu)).andReturn(null);
EasyMock.replay(service);
Henri
  • 5,551
  • 1
  • 22
  • 29
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63

1 Answers1

2

Have you tried

EasyMock.verify(service);
EasyMock.verify(menu);

Or alternatively

EasyMock.verifyAll();
James
  • 1,095
  • 7
  • 20
  • that's working !! Thank you James. Do I have to use replay before verify as well? As I read from forums, I have to use replay in order to activate the test but it seems not it is not required. – Tonyukuk Mar 01 '17 at 12:02
  • It will make no difference in the code in your question. You still want replay, for when actually test behaviour. – James Mar 01 '17 at 12:55