Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:32:51+00:00 2026-05-28T17:32:51+00:00

The EasyMock framework (mocks for Java) has very clever method createNiceMock , it is:

  • 0

The EasyMock framework (mocks for Java) has very clever method createNiceMock, it is:

Creates a mock object that implements the given interface, order checking is disabled by default, and the mock object will return 0, null or false for unexpected invocations.

I wonder about some equivalent method in Rhino Mocks framework that can mocks with 0, null or false for unexpected invocations (I am not interesting in order checking but if it will be it will OK too)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:32:53+00:00Added an answer on May 28, 2026 at 5:32 pm

    Those are characteristics of dynamic mock:

    Dynamic Mock – Loose replay semantics. Created by calling DynamicMock()

    Loose replay semantics: All method calls during the replay state are accepted. If there is no special handling setup for a given method, a null or zero is returned. All of the expected methods must be called for the object to pass verification.

    In earlier versions of you had to explicitly create one:

    var mocks = new MockRepository();
    var service = mocks.DynamicMock<IService>();
    

    Nowadays, by default mocks are assumed to be dynamic mocks as long as you create them with MockRepository.GenerateMock<T>() method. Expectations call order is also irrelevant. Assuming we got expectations set up as below:

    var dependency = MocksRepository.GenerateMock<IDependency>();
    dependency.Expect(d => d.SecondMethod());
    dependency.Expect(d => d.FirstMethod());
    

    Tested code like the example below

    public void DoWork()
    {
        this.Dependency.FirstMethod();
        this.Dependency.SecondMethod();
        this.Dependency.ThirdMethod();
    }
    

    won’t cause the test to fail. Order doesn’t matter, unexpected invocations are ignored and return default values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create a mock object that implements several interfaces with EasyMock?
I'm mocking a method with easymock that has a date in its body, something
Mock frameworks, e.g. EasyMock, make it easier to plugin dummy dependencies. Having said that,
Is it possible to do something like that with EasyMock: class ClassName{ void method(){
I was thinking, is it possible to mock whole object behavior with EasyMock, but
Using the latest version of EasyMock, I have a method that I need to
Thanks to a library upgrade (easymock 2.2 -> 2.4), we're having tests that have
This comparison shows, that JMockit has several advantages over other frameworks. Are there also
I'm getting a java.lang.noclassdeffounderror when trying to create a mock class for Component using
I found this example where they used PowerMock and EasyMock to stub/mock the Menu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.