It's not a secret anymore!
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Easy Mock Test Case" Watch "Easy Mock Test Case" New topic

Easy Mock Test Case

kri shan
Ranch Hand

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

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

Joined: Feb 26, 2001
Posts: 6496

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

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:

I agree. Here's the link:
subject: Easy Mock Test Case
jQuery in Action, 3rd edition