Attempt to mockito mock any class generates ExceptionInInitializerError

前端 未结 7 1495
無奈伤痛
無奈伤痛 2020-12-16 09:26

When I run the following code:

public class ActivityTest extends ActivityInstrumentationTestCase2 {
    ....
    public void testCanCreat         


        
相关标签:
7条回答
  • 2020-12-16 10:19

    User23's answer is close to the solution that worked for me.

    According to the official documentation you have to do the following things to activate Mockito in your Android app:

    1. Download dexmaker-1.4.jar and dexmaker-mockito-1.4.jar and put them into your libs folder.
    2. Add the following dependencies into your build.gradle:

      androidTestCompile "org.mockito:mockito-core:1.10.19"
      androidTestCompile fileTree(dir: 'libs', include: ['dexmaker-1.4.jar']) androidTestCompile fileTree(dir: 'libs', include: ['dexmaker-mockito-1.4.jar'])

    0 讨论(0)
提交回复
热议问题