java.lang.IllegalStateException: Missing invocation to mocked type at this point; please make sure such invocations appear only after the declaration of a suitable mock field or parameter

GitHub | Thunderforge | 7 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Using invoke() on a partially-mocked @Tested object passes on JMockit 1.22, fails on JMockit 1.23+

    GitHub | 7 months ago | Thunderforge
    java.lang.IllegalStateException: Missing invocation to mocked type at this point; please make sure such invocations appear only after the declaration of a suitable mock field or parameter

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Missing invocation to mocked type at this point; please make sure such invocations appear only after the declaration of a suitable mock field or parameter

      at com.example.JMockitIssueClassTest$1.<init>()
    2. com.example
      JMockitIssueClassTest.publicBooleanMethodTest
      1. com.example.JMockitIssueClassTest$1.<init>(JMockitIssueClassTest.java:28)
      2. com.example.JMockitIssueClassTest.publicBooleanMethodTest(JMockitIssueClassTest.java:26)
      2 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:606)
      2 frames
    4. IntelliJ junit4 module
      JUnit4IdeaTestRunner.startRunnerWithArgs
      1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
      2. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      2 frames
    5. IDEA
      JUnitStarter.main
      1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:253)
      2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
      2 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:606)
      2 frames
    7. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
      1 frame