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 | 6 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

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

    GitHub | 6 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