Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#25 Use a single MocksControl for multiple mock types

EasyMock (33)
Aaron Pieper

It would be convenient if we could use a single mock control to simultaneously control nice, default and strict mocks simultaneously.

It is common for our unit tests to want to use different mock types in a single test. For example, we might inject a "nice" logger mock, and a "strict" data-access mock. Since this behavior is not supported by EasyMock's MocksControl class as of EasyMock 2.4, we have written our own class to suit our needs (attached).

It would be ideal if there were functionality built into EasyMock which made this custom class unnecessary. This might come either as a modification to MocksControl, or as a new class which extends the functionality of MocksControl.


  • Aaron Pieper
    Aaron Pieper

    Our custom "EasyMockMaker" class, which mostly duplicates MocksControl but adds the functionality for multiple mock types

  • Henri Tremblay
    Henri Tremblay

    IMocksControl creates related mocks. For instance, they are ordered with one another in case of a strict IMocksControl.

    What you want is some kind of mock factory to be able de replay and verify quickly. That's requested a lot. I'm not quite sure of the best way to do so but I'll look into it.


  • Anonymous

    This feature request appears to be fulfilled by the new EasyMockSupport class. I think this tracker can be closed.