相关疑难解决方法(0)

java.lang.IllegalStateException:无法初始化插件:MockMaker

尝试在AS上运行检测测试.

坚持这个错误:

java.lang.IllegalStateException:无法在java.lang.reflect.Proxy上的org.mockito.internal.configuration.plugins.PluginLoader $ 1.invoke(PluginLoader.java:66)初始化插件:interface org.mockito.plugins.MockMaker.在$ Proxy4.isTypeMockable(未知来源)调用(Proxy.java:393)

ExampleInstrumentedTest.java

      @RunWith(AndroidJUnit4.class)
        public class ExampleInstrumentedTest {

            @Mock
            Context context;

  @Before
    public void init(){
        MockitoAnnotations.initMocks(this);
    }

        @Test
            public void testDisabledFlag()  {
                ChanceValidator chanceValidator  = new ChanceValidator(context);
                Validator.ValidationResult result = chanceValidator.validate(2);
                assertEquals(result, Validator.ValidationResult.NO_ERROR);
        }
       }
Run Code Online (Sandbox Code Playgroud)


的build.gradle

apply plugin: 'com.android.application'

     android{
        ..
        defaultConfig {
                testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

         testOptions {
                unitTests.returnDefaultValues = true
            }
    }


    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        // Unit testing dependencies
        testCompile 'junit:junit:4.12'
        // Set this dependency if you want to use …
Run Code Online (Sandbox Code Playgroud)

android mockito

9
推荐指数
2
解决办法
1万
查看次数

适用于Android Instrumentation测试的Mockito 2:无法初始化插件:接口org.mockito.plugins.MockMaker

我正在使用Mockito 2和Espresso进行单元测试,并且在尝试在Instrumentation测试中使用Mockito 2时遇到了问题。运行测试时,出现此错误

java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:74)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy5.isTypeMockable(Unknown Source)
at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:232)
at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:226)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
at org.mockito.Mockito.mock(Mockito.java:1864)
at org.mockito.Mockito.mock(Mockito.java:1777)
at com.armop.insight.views.activity.InsightActivityTest.testUserResultReturnsEmpty(InsightActivityTest.kt:66)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) …
Run Code Online (Sandbox Code Playgroud)

android mockito kotlin android-espresso byte-buddy

8
推荐指数
2
解决办法
4165
查看次数

标签 统计

android ×2

mockito ×2

android-espresso ×1

byte-buddy ×1

kotlin ×1