[Kotlin Android] Kotlin Android starter based MVP/Dagger2/RxJava2/Robolectric/Espresso/Mockito. It provides a generator to fast create a Kotlin Android project.
I cloned your repository and tried to run the Instrumented Test for the MainActivity (MainActivityTest), but it keeps raising the following error:
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class io.mvpstarter.sample.data.DataManager
Mockito cannot mock/spy because :
- final class
at io.mvpstarter.sample.common.injection.module.ApplicationTestModule.providesDataManager$app_debug(ApplicationTestModule.kt:39)
at io.mvpstarter.sample.common.injection.module.ApplicationTestModule_ProvidesDataManager$app_debugFactory.get(ApplicationTestModule_ProvidesDataManager$app_debugFactory.java:20)
at io.mvpstarter.sample.common.injection.module.ApplicationTestModule_ProvidesDataManager$app_debugFactory.get(ApplicationTestModule_ProvidesDataManager$app_debugFactory.java:8)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at io.mvpstarter.sample.common.injection.component.DaggerTestComponent.dataManager(DaggerTestComponent.java:69)
at io.mvpstarter.sample.common.TestComponentRule.getMockDataManager(TestComponentRule.kt:32)
at io.mvpstarter.sample.MainActivityTest.stubDataManagerGetPokemonList(MainActivityTest.kt:71)
at io.mvpstarter.sample.MainActivityTest.checkPokemonsDisplay(MainActivityTest.kt:39)
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.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at io.mvpstarter.sample.common.TestComponentRule$apply$1.evaluate(TestComponentRule.kt:40)
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)
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.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:369)
at io.mvpstarter.sample.runner.UnlockDeviceAndroidJUnitRunner.onStart(UnlockDeviceAndroidJUnitRunner.kt:29)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1960)
Is the error "right" or am I doing something wrong?
I also tried to copy the .MockMaker file to the androidTest directory, but it raises another error:
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:66)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at $Proxy4.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:186)
at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:180)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
at org.mockito.Mockito.mock(Mockito.java:1729)
at org.mockito.Mockito.mock(Mockito.java:1642)
at io.mvpstarter.sample.common.injection.module.ApplicationTestModule.providesDataManager$app_debug(ApplicationTestModule.kt:39)
at io.mvpstarter.sample.common.injection.module.ApplicationTestModule_ProvidesDataManager$app_debugFactory.get(ApplicationTestModule_ProvidesDataManager$app_debugFactory.java:20)
at io.mvpstarter.sample.common.injection.module.ApplicationTestModule_ProvidesDataManager$app_debugFactory.get(ApplicationTestModule_ProvidesDataManager$app_debugFactory.java:8)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at io.mvpstarter.sample.common.injection.component.DaggerTestComponent.dataManager(DaggerTestComponent.java:69)
at io.mvpstarter.sample.common.TestComponentRule.getMockDataManager(TestComponentRule.kt:32)
at io.mvpstarter.sample.MainActivityTest.stubDataManagerGetPokemonList(MainActivityTest.kt:71)
at io.mvpstarter.sample.MainActivityTest.checkErrorViewDisplays(MainActivityTest.kt:65)
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.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at io.mvpstarter.sample.common.TestComponentRule$apply$1.evaluate(TestComponentRule.kt:40)
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)
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.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:369)
at io.mvpstarter.sample.runner.UnlockDeviceAndroidJUnitRunner.onStart(UnlockDeviceAndroidJUnitRunner.kt:29)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1960)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.TwoEnumerationsInOne@cf7f577
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:101)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:45)
at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:18)
at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:17)
at org.mockito.internal.configuration.plugins.Plugins.getMockMaker(Plugins.java:33)
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
... 45 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)
I have a project similar to yours, and I'm struggling almost a week to configure Mockito 2.x + Dagger 2 + Kotlin.
Hi folks,
I cloned your repository and tried to run the Instrumented Test for the MainActivity (MainActivityTest), but it keeps raising the following error:
Is the error "right" or am I doing something wrong?
I also tried to copy the .MockMaker file to the androidTest directory, but it raises another error:
I have a project similar to yours, and I'm struggling almost a week to configure Mockito 2.x + Dagger 2 + Kotlin.
Regards, Luan.