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 6592851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:36:30+00:00 2026-05-25T17:36:30+00:00

What is the difference between this: ResultSet set = EasyMock.createNiceMock(ResultSet.class); EasyMock.expect(set.getInt(col1)).andReturn(1); EasyMock.expect(set.wasNull()).andReturn(false); EasyMock.expect(set.getInt(col2)).andReturn(2); EasyMock.expect(set.wasNull()).andReturn(false);

  • 0

What is the difference between this:

ResultSet set = EasyMock.createNiceMock(ResultSet.class);
EasyMock.expect(set.getInt("col1")).andReturn(1);
EasyMock.expect(set.wasNull()).andReturn(false);
EasyMock.expect(set.getInt("col2")).andReturn(2);
EasyMock.expect(set.wasNull()).andReturn(false);
EasyMock.replay(set);

assertEquals(1, set.getInt("col1"));
assertEquals(false, set.wasNull());
assertEquals(2, set.getInt("col2"));
assertEquals(false, set.wasNull());

And this:

ResultSet set = EasyMock.createNiceMock(ResultSet.class);
EasyMock.expect(set.getInt("col1")).andReturn(1);
EasyMock.expect(set.getInt("col2")).andReturn(2);
EasyMock.expect(set.wasNull()).andReturn(false).times(2);
EasyMock.replay(set);

assertEquals(1, set.getInt("col1"));
assertEquals(false, set.wasNull());
assertEquals(2, set.getInt("col2"));
assertEquals(false, set.wasNull());

?

Note: both sets of code compile and run successfully as jUnit tests. Also, note that the use of a “nice” mock is on purpose here.

  • 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-25T17:36:31+00:00Added an answer on May 25, 2026 at 5:36 pm

    To answer the question in your title – there’s no difference. Calling x.expect(y).times(3) is exactly the same as calling

    x.expect(y);
    x.expect(y);
    x.expect(y);
    

    (Note that as pointed out by Andy Thomas-Cramer, your specific examples aren’t entirely equivalent because the order of calls differ.)

    This might just seem like a convenience issue. However there’s a distinct difference beyond this: in that the times() case you can pass in the expected number of calls as a variable. Consequently you can make this configurable by some external file, or even simply by a public constant int which you also use to fire off the test harness. It’s a lot more flexible than having to explicitly compile the correct number of calls to expect() (and update your code if you now need to test with five workers instead of three).

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

Sidebar

Related Questions

what would be the difference between this class Class1 { public string prop1 {
What is the difference between this two codes? class SomeClass { SomeType val =
What is the difference between this: this.btnOk.Click += new System.EventHandler(this.btnOK_Click); and this? this.btnOk.Click +=
Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();
I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something
What's the point using this syntax div.card > div.name What's the difference between this
I just noticed a new term pimpl idiom, what's the difference between this idiom
What's the difference between these: This one works: char* pEmpty = new char; *pEmpty
Is there a difference between Cursor.Current and this.Cursor (where this is a WinForm) in
What's the difference between reading a value from an SqlDataReader using this syntax: Dim

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.