File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Easy Mock Test Case Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Easy Mock Test Case" Watch "Easy Mock Test Case" New topic
Author

Easy Mock Test Case

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1372
Got folowing EasyMock exception.

[testng] java.lang.IllegalStateException: matcher calls were used outside expectations
[testng] at org.easymock.internal.RecordState.replay(RecordState.java:84)
[testng] at org.easymock.internal.MocksControl.replay(MocksControl.java:97)
[testng] at org.easymock.EasyMock.replay(EasyMock.java:1540)
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4456
    
    6

Did you have a specific question about this? IllegalStateException usually means you need to ensure certain pre-conditions exist before calling a method on an object. Go to the JavaDocs for the class/method that's throwing the exception to see what those pre-conditions are.


Junilu - [How to Ask Questions] [How to Answer Questions]
tom kalafut
Greenhorn

Joined: Dec 03, 2012
Posts: 1
The exception is reported on the call to replay(), but it's caused by a matcher outside of an expectation. How can I determine where the problem is?

I re-read my code several times to make sure that every void return method called on a mock object with matchers is followed by an expectLastCall(). Example:

payment.setAuthKey(eq(42));
expectLastCall();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Easy Mock Test Case