2011-01-05 2 views
2

モック録音時にこの例外が発生します。 私はこのフォーラムで解決策を探してみました。私は他のパラメータを壊さないようにしました。3つのマッチャーが予想され、4つが記録された

以下の模擬予想ではエラーが発生しています。

EasyMock.expect(slotManager.addSlotPageletBinding(EasyMock.isA(String.class), EasyMock.isA(String.class), EasyMock.isA(helloWorld.class))).andReturn(true); 

私はこのメソッドの前に、2つのパラメータ(オーバーロードされたメソッド)を持つ同じメソッドについて別の疑問を持っています。以下はそのモックです。

EasyMock.expect(slotManager.addSlotPageletBinding(EasyMock.isA(String.class),EasyMock.isA(String.class))).andReturn(true).anyTimes(); 

いずれにしても私にこれをガイドできますか?ありがとう。

java.lang.IllegalStateException: 3 matchers expected, 4 recorded. 
    at org.easymock.internal.ExpectedInvocation.createMissingMatchers(ExpectedInvocation.java:56) 
    at org.easymock.internal.ExpectedInvocation.<init>(ExpectedInvocation.java:48) 
    at org.easymock.internal.ExpectedInvocation.<init>(ExpectedInvocation.java:40) 
    at org.easymock.internal.RecordState.invoke(RecordState.java:76) 
    at org.easymock.internal.MockInvocationHandler.invoke(MockInvocationHandler.java:38) 
    at org.easymock.internal.ObjectMethodsFilter.invoke(ObjectMethodsFilter.java:72) 
    at org.easymock.classextension.internal.ClassProxyFactory$1.intercept(ClassProxyFactory.java:79) 
    at com.amazon.inca.application.SlotManager$$EnhancerByCGLIB$$3bf5ac02.addSlotPageletBinding(<generated>) 
    at com.amazon.iris3.apps.Iris3YourAccountApplicationTest.testBuildIncaViewConfiguration(Iris3YourAccountApplicationTest.java:107) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at junit.framework.TestCase.runTest(TestCase.java:168) 
    at junit.framework.TestCase.runBare(TestCase.java:134) 
    at junit.framework.TestResult$1.protect(TestResult.java:110) 
    at junit.framework.TestResult.runProtected(TestResult.java:128) 
    at junit.framework.TestResult.run(TestResult.java:113) 
    at junit.framework.TestCase.run(TestCase.java:124) 
    at junit.framework.TestSuite.runTest(TestSuite.java:232) 
    at junit.framework.TestSuite.run(TestSuite.java:227) 
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 
+0

http://stackoverflow.com/questions/6550036/easymock-java-lang-illegalstateexception-1-matchers-expected-2-recorded言い換えれば、リプレイを呼び出した後にマッチャーを作成しないように注意してください。 – rogerdpack

答えて

1

問題は、あなたのモックの3つの期待(通話)を記録したが、テストの実行中にモックのメソッドの4回の呼び出しがあったです。あなたはどこかで1つのコールを見逃しています。テスト中のコードをさらに読んで、不足しているコールを発見してください。または、デバッガを使用して検出します。

関連する問題