Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EasyMock should behave normally after a failure #17

Closed
henri-tremblay opened this issue Jun 3, 2015 · 0 comments
Closed

EasyMock should behave normally after a failure #17

henri-tremblay opened this issue Jun 3, 2015 · 0 comments
Assignees
Milestone

Comments

@henri-tremblay
Copy link
Contributor

Migrated from: CodeHaus issue EASYMOCK-6
Original reporter: Henri Tremblay


Submitted by Mike Dunbar

Running the main method of this class demonstrates the issue.


public class DemoEasyMockIssue {
public static interface TheInterface {
public String foo();
public String bar();
}

public static void main(String[] args) {
TheInterface mock =
createMock(TheInterface.class);
expect(mock.foo()).andReturn("foo").anyTimes();
replay(mock);
mock.foo();
System.out.println("Calling foo works as "+
"anticipated, before the call to bar.");

  try {
     mock.bar();
  }
  catch(AssertionError error) {
     System.out.println("Calling bar gives the " + 
        "anticipated error: " + error);
  }

  try {
     mock.foo();
  }
  catch(AssertionError error) {
     System.out.println("Calling foo again after" +   
        "bar gives an unanticipated error: " +  
        error);
  }

}

}

To me it seems like a bug that mocks report expected calls as unexpected, after any call to an unexpected method. At the very least, the error message is misleading because it only says that the expected
method call was unexpected. I'm sure it's probably the case that you would normally be calling the unexpected method as part of a test, fail before you ever try and make a subsequent call on the expected method, and this wouldn't matter. But due to one of the automated testing tools that we use this isn't desirable. I would like subsequent calls to expected methods to behave based on the recording.

Is this reasonable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant