• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

easyMock - AssertionError problem

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to write a simple test to check if the details of a DVD store. I want to get a summary back of the requested dvd. When i run the test it says

getDvdSummary("DVD-S765"):expected:1,actual:0

Here is some of the code:
/*
@Test
public void shouldReturnSummaryOfRequstedDVD() throws DvdNotFoundException {
expect(dvdServiceInterface.getDvdSummary("DVD-S765")).andReturn("DVD-S765 Shrek - Green monsters seem to be all the rage these days...");
replayMocks();
DvdServiceImpl ds = new DvdServiceImpl();
assertEquals(ds.getDvdSummary("DVD-S765"),"DVD-S765 Shrek - Green monsters seem to be all the rage these days...");
verifyMocks();
}
private void verifyMocks() {
verify(dvdServiceInterface);
}
private void replayMocks() {
replay(dvdServiceInterface);
}

*/

Can someone tplease tell me what is wrong with this line? Thank You!

expect(dvdServiceInterface.getDvdSummary("DVD-S765")).andReturn("DVD-S765 Shrek - Green monsters seem to be all the rage these days...");
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're setting expectations on the mock but you're exercising the real thing. Thus, the method is never called on the mock. Thus, the mock complains about unsatisfied expectations.
 
I want my playground back. Here, I'll give you this tiny ad for it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic