久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

嘗試模擬任何類(lèi)都會(huì)生成 ExceptionInInitializerError

Attempt to mockito mock any class generates ExceptionInInitializerError(嘗試模擬任何類(lèi)都會(huì)生成 ExceptionInInitializerError)
本文介紹了嘗試模擬任何類(lèi)都會(huì)生成 ExceptionInInitializerError的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

當(dāng)我運(yùn)行以下代碼時(shí):

public class ActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
    ....
    public void testCanCreateMockito() {
        List mockedList = Mockito.mock(List.class);
    }
}

我得到以下異常:

java.lang.ExceptionInInitializerError
at org.mockito.internal.creation.cglib.ClassImposterizer.createProxyClass(ClassImposterizer.java:95)
at org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:57)
at org.mockito.internal.creation.cglib.ClassImposterizer.imposterise(ClassImposterizer.java:49)
at org.mockito.internal.creation.cglib.CglibMockMaker.createMock(CglibMockMaker.java:24)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:33)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:59)
at org.mockito.Mockito.mock(Mockito.java:1285)
at org.mockito.Mockito.mock(Mockito.java:1163)
at com.acesounderglass.hungertracker.ActivityTest.testCanCreateMockito(ActivityTest.java:60)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)
Caused by: org.mockito.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:238)
at org.mockito.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:117)
at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:109)
at org.mockito.cglib.core.KeyFactory.create(KeyFactory.java:105)
at org.mockito.cglib.proxy.Enhancer.<clinit>(Enhancer.java:70)
... 23 more
Caused by: java.lang.reflect.InvocationTargetException
at org.mockito.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:385)
at org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:220)
... 28 more
Caused by: java.lang.UnsupportedOperationException: can't load this type of class file
at java.lang.ClassLoader.defineClass(ClassLoader.java:300)
... 32 more

這發(fā)生在任何類(lèi)中,List 只是一個(gè)簡(jiǎn)單的例子.我的 gradle 依賴(lài)項(xiàng)是:

This occurs with any class, List was just an easy example. My gradle dependencies are:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.0'
    androidTestCompile "org.mockito:mockito-core:1.+"
    androidTestCompile files('libs/dexmaker-mockito-1.0.jar')
    androidTestCompile files('libs/dexmaker-1.0.jar')
}

我已將 gradle 升級(jí)到 1.1,嘗試使用實(shí)驗(yàn)性單元測(cè)試功能,但沒(méi)有,似乎沒(méi)有任何區(qū)別.怎么回事?

I've upgraded gradle to 1.1, tried using the experimental unit test feature and not, nothing seems to make a difference. What's going on?

推薦答案

我在缺少兩個(gè) dexmaker 依賴(lài)項(xiàng)時(shí)收到此錯(cuò)誤.

I received this error when I was missing the two dexmaker dependencies.

將這些行添加到 app/gradle.build 文件對(duì)我有用.

Adding these lines to the app/gradle.build file is working for me.

androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'

我也在使用 Android Studio,發(fā)現(xiàn)更改依賴(lài)項(xiàng)后重啟 AS 是個(gè)好主意.

I am also using Android Studio and have found it to be a good idea to restart AS after altering the dependencies.

這篇關(guān)于嘗試模擬任何類(lèi)都會(huì)生成 ExceptionInInitializerError的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標(biāo)簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測(cè)向左或向右滑動(dòng)?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉(zhuǎn)對(duì)話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點(diǎn)擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設(shè)置為僅接受 Android 中的數(shù)值?)
主站蜘蛛池模板: 国产精品久久久久久久久久了 | 91伊人网| 在线日韩不卡 | 国产视频久久久 | 日本视频一区二区三区 | 91久久久久久 | 日韩精品成人免费观看视频 | 黄瓜av | 男人av的天堂 | 久久爱一区 | 免费在线观看黄网站 | 不卡一二三区 | 国产精品一区二区三区四区五区 | 成人国产免费观看 | 国产视频欧美 | 亚洲精品福利在线 | 日本精品一区二区三区在线观看视频 | 一级欧美 | 久久久国产精品 | 国产精品久久久久av | 超碰最新在线 | 婷婷丁香在线视频 | 亚洲免费在线观看av | 一区二区三区在线 | 国产免费人成xvideos视频 | 黄网站免费在线看 | 亚洲成av | 亚洲成人精品久久 | 草久视频 | 91久久久www播放日本观看 | 国产日韩一区二区 | 欧美黄色精品 | 黄色毛片在线观看 | 亚洲欧洲小视频 | 日韩国产中文字幕 | 激情五月婷婷丁香 | 国产精品久久久久久久久免费相片 | www.天天操| 国产午夜在线 | 国产91丝袜在线播放 | 国产精品一区二区三区在线 |