Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EasyMock Vs JUnit

 
vivek dhiman
Ranch Hand
Posts: 153
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I was going through the mocking framework for the testing purpose. Can someone post sample code where i can see test though junit will be not appropriate as compare with easymock.

Thanks
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EasyMock is a tool you use in your JUnit tests, not something that replaces JUnit. Are you asking for an example of where EasyMock would be useful?
 
vivek dhiman
Ranch Hand
Posts: 153
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks

I have an example, below is the test code.


When I remove the verify method, Test gets Pass but when i apply it gets fail. It shows the assertion error :



Any advice



 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, you are telling EasyMock that getPrice("EBAY") will be called once on marketMock, and to return 20.0 when that happens. However you try to verify that result before performing any actions that would make the call. Try moving the verify to the last line of the test.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic