org.mockito.exceptions.base.MockitoException: Could not look up implicit location for storing generated classes You can configure an explicit location by setting the system property 'org.mockito.android.target' to a folder for storing generated class files This location must be in private scope for most API versions, for example: MyActivity.this.getDir("target", Context.MODE_PRIVATE) or getInstrumentation().getTargetContext().getCacheDir().getPath()

GitHub | vipheyue | 1 month ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    i use public class but can't mock instance

    GitHub | 1 month ago | vipheyue
    org.mockito.exceptions.base.MockitoException: Could not look up implicit location for storing generated classes You can configure an explicit location by setting the system property 'org.mockito.android.target' to a folder for storing generated class files This location must be in private scope for most API versions, for example: MyActivity.this.getDir("target", Context.MODE_PRIVATE) or getInstrumentation().getTargetContext().getCacheDir().getPath()
  2. 0

    MissingMethodInvocationException testing an opened class in Kotlin

    Stack Overflow | 10 months ago | cesards
    org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'. For example: when(mock.getArticles()).thenReturn(articles); Also, this error might show up because: 1. you stub either of: final/private/equals()/hashCode() methods. Those methods *cannot* be stubbed/verified. Mocking methods declared on non-public parent classes is not supported. 2. inside when() you don't call method on mock but on some other object.
  3. 0

    Mockito's spy functionality fails

    Stack Overflow | 9 months ago | Ankit Khettry
    org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'. For example: when(mock.getArticles()).thenReturn(articles); Also, this error might show up because: 1. you stub either of: final/private/equals()/hashCode() methods. Those methods *cannot* be stubbed/verified. 2. inside when() you don't call method on mock but on some other object. 3. the parent of the mocked class is not public. It is a limitation of the mock engine.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    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. org.mockito.exceptions.base.MockitoException

      Could not look up implicit location for storing generated classes You can configure an explicit location by setting the system property 'org.mockito.android.target' to a folder for storing generated class files This location must be in private scope for most API versions, for example: MyActivity.this.getDir("target", Context.MODE_PRIVATE) or getInstrumentation().getTargetContext().getCacheDir().getPath()

      at net.bytebuddy.TypeCache.findOrInsert()
    2. Byte Buddy (with dependencies)
      TypeCache$WithInlineExpunction.findOrInsert
      1. net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:138)
      2. net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:346)
      3. net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:161)
      4. net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:355)
      4 frames
    3. com.vipheyue.mockitotest
      ExampleUnitTest.mockitoTest1
      1. com.vipheyue.mockitotest.ExampleUnitTest.mockitoTest1(ExampleUnitTest.java:36)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames
    5. JUnit
      JUnitCore.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      13. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      14. org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      14 frames
    6. IntelliJ junit4 module
      JUnit4IdeaTestRunner.startRunnerWithArgs
      1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
      2. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      2 frames
    7. IDEA
      JUnitStarter.main
      1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
      2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
      2 frames
    8. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames
    9. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
      1 frame