This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Easy Mock Test Case  RSS feed

 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11144
160
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
tom kalafut
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!