java.lang.IllegalStateException: Expected 3 calls, received 2

Spring JIRA | Erik-Jan Blanksma | 7 years ago
  1. 0

    When doing multiple assertions in a test created using the procedure described in ROO-92 , and an assertion failes (not the last one), than the actual AssertionFailedError is swallowed by the verify method in the AbstractMockingControl class, obscuring the actual error: java.lang.IllegalStateException: Expected 3 calls, received 2 at com.wedding.mock.AbstractMethodMockingControl$Expectations.verify(AbstractMethodMockingControl.aj:85) at com.wedding.mock.AbstractMethodMockingControl.ajc$after$com_wedding_mock_AbstractMethodMockingControl$1$94476acf(AbstractMethodMockingControl.aj:152) at com.wedding.domain.RsvpTest.testMethod2(RsvpTest.java:37) 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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:220) 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)

    Spring JIRA | 7 years ago | Erik-Jan Blanksma
    java.lang.IllegalStateException: Expected 3 calls, received 2
  2. 0

    When doing multiple assertions in a test created using the procedure described in ROO-92 , and an assertion failes (not the last one), than the actual AssertionFailedError is swallowed by the verify method in the AbstractMockingControl class, obscuring the actual error: java.lang.IllegalStateException: Expected 3 calls, received 2 at com.wedding.mock.AbstractMethodMockingControl$Expectations.verify(AbstractMethodMockingControl.aj:85) at com.wedding.mock.AbstractMethodMockingControl.ajc$after$com_wedding_mock_AbstractMethodMockingControl$1$94476acf(AbstractMethodMockingControl.aj:152) at com.wedding.domain.RsvpTest.testMethod2(RsvpTest.java:37) 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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:220) 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)

    Spring JIRA | 7 years ago | Erik-Jan Blanksma
    java.lang.IllegalStateException: Expected 3 calls, received 2
  3. 0

    3 matchers expected, 4 recorded

    Stack Overflow | 6 years ago | user564159
    java.lang.IllegalStateException: 3 matchers expected, 4 recorded.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Scott Leberknight's Weblog

    sleberknight.com | 9 months ago
    java.lang.IllegalStateException: 3 matchers expected, 1 recorded.
  6. 0

    jira.codehaus.org

    espertech.com | 4 months ago
    java.lang.IllegalStateException: Expected identifier but received type '134'

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Expected 3 calls, received 2

      at com.wedding.mock.AbstractMethodMockingControl$Expectations.verify()
    2. com.wedding.mock
      AbstractMethodMockingControl.ajc$after$com_wedding_mock_AbstractMethodMockingControl$1$94476acf
      1. com.wedding.mock.AbstractMethodMockingControl$Expectations.verify(AbstractMethodMockingControl.aj:85)
      2. com.wedding.mock.AbstractMethodMockingControl.ajc$after$com_wedding_mock_AbstractMethodMockingControl$1$94476acf(AbstractMethodMockingControl.aj:152)
      2 frames
    3. com.wedding.domain
      RsvpTest.testMethod2
      1. com.wedding.domain.RsvpTest.testMethod2(RsvpTest.java:37)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. JUnit
      ParentRunner.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      6. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
      8. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
      9. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
      10. org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
      11. org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
      12. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      13. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
      14. org.junit.runners.ParentRunner.run(ParentRunner.java:220)
      14 frames
    6. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
      1 frame
    7. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      5 frames