• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • EasyMock
  • Bugs

Using a matcher causes a failure in next expectation

Brought to you by: tammofreese
  • Summary
  • Files
  • Reviews
  • Support
  • Code
  • Cvs
  • Tickets ▾
    • Bugs
    • Feature Requests
Menu ▾ ▴
  • Create Ticket
  • View Stats

Group

  • EasyMock_2.4
  • EasyMock_2.5
  • EasyMock_2.5.2
  • EasyMock_3.0
  • EasyMock_CE_2.4
  • EasyMock_CE_2.5
  • EasyMock_CE_3.0
  • v1.0_(example)

Searches

  • Changes
  • Closed Tickets
  • Open Tickets

Help

  • Formatting Help

#48 Using a matcher causes a failure in next expectation

EasyMock_3.0
open
nobody
EasyMock (40)
5
2012-10-05
2011-04-11
Gaetan PItteloud
No

I need to test a Service class that depends on the Factory (interface). The factory creates objects of type ExtendedSession (concrete class). When a session is created in the service, it calls the open method (which is defined on the superclass of ExtendedSession : Session, a concrete class), then the getValue method, (which is defined on the super-superclass of ExtendedSession : BaseSession, a concrete class). Both methods don't accept parameters, and return int.
In the test, I create a mock for Factory and a mock for ExtendedSession, then I expect a call to the factory that returns the mock session, then a call to session.open() that returns anyInt(), and a call to session.getValue() that returns 5. In the 2nd expectation, I get a mismatched matchers exception that states "0 matchers expected, 1 recorded". When I change the first expectation so that it returns a real value (say 3), the test passes.

You can see things in real within the attached zipped classes.
Thanks for your help

Discussion

  • Gaetan PItteloud

    Gaetan PItteloud - 2011-04-11
     
    em.zip
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Log in to post a comment.

SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2026 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
MongoDB Logo MongoDB