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

使用 mockito 庫的 android 應用程序的 Jacoco 代碼覆蓋

Jacoco code coverage for android application using mockito library(使用 mockito 庫的 android 應用程序的 Jacoco 代碼覆蓋率)
本文介紹了使用 mockito 庫的 android 應用程序的 Jacoco 代碼覆蓋率的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的 android 應用程序使用以下配置:

My android application uses the following config:

  • Gradle - 0.12.+

build.gradle 文件的內容

Contents of build.gradle file

buildscript {
repositories {
    mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:0.12.+'
}
}

repositories {
mavenLocal()
mavenCentral()
}

apply plugin: 'com.android.library'
apply plugin: "jacoco"



dependencies {

compile 'commons-collections:commons-collections:3.2.1'
compile 'org.slf4j:slf4j-android:1.6.1-RC1'

// dependency injection
compile('org.roboguice:roboguice:2.0') {
    exclude module: 'cglib'
    exclude module: 'aopalliance'
    exclude module: 'guice'
}

compile files('libs/guice-3.0-no_aop.jar')
compile 'javax.inject:javax.inject:1'



/*
 * Test dependencies.
 */
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'

}

android {
buildToolsVersion "20.0"
compileSdkVersion 19

buildTypes {
    debug {
        runProguard false
        testCoverageEnabled true
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 19
    versionCode 100
    versionName "1.0.0"
}

/*
 * Workaround for packaging bug in Android Gradle plugin regarding duplicate files.
 */
packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'LICENSE.txt'
}
}

當屬性 testCoverageEnabled 設置為 false 時,我的所有測試都會成功運行.將其設置為 true 時,運行測試時會引發以下異常

All my tests run successfully when property testCoverageEnabled is set to false. On setting it to true, the following exception is thrown when running the tests

Caused by: java.lang.VerifyError: *** Some class ***
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:211)
at dalvik.system.DexPathList.findClass(DexPathList.java:313)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:51)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)

當在測試中初始化模擬時,錯誤發生在行上.

The error happens on the line when mocks are initialised within the tests.

有沒有人設法為使用 mockito 庫進行測試的 android 應用程序生成代碼覆蓋率指標?

Has anyone managed to generate code coverage metrics for android application which uses mockito library for testing?

推薦答案

以下鏈接對我遇到的問題非常有用:http://www.androidpuzzles.com/168_17620080/

The following link was very useful in explaining the problem I encountered: http://www.androidpuzzles.com/168_17620080/

隨后我將源和目標兼容性設置切換到 Java 1.5,并且能夠運行單元和 UI 測試(使用 mockito 和 espresso)并使用 Jacoco 生成代碼覆蓋率報告.

I subsequently switched the source and target compatibility settings to Java 1.5 and I was able to run the unit and UI tests (which used both mockito and espresso) and generate code coverage report using Jacoco.

如果我必須保留 Java 1.7 設置,解決方法是將被測試類中私有方法的范圍更改為受保護或公共范圍.這將允許我生成代碼覆蓋率報告(克服包含的鏈接中確定的問題).

If I had to retain Java 1.7 settings, the workaround would have been to change the scope of private methods in the class being tested to either protected or public scope. This would have then allowed me to generate the code coverage report (overcoming the issue as identified in the link included).

這篇關于使用 mockito 庫的 android 應用程序的 Jacoco 代碼覆蓋率的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

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 操作標簽的多行 EditText)
How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
主站蜘蛛池模板: 日本久久久久久久久 | 国产日韩欧美 | 日韩在线中文字幕 | 毛片网在线观看 | 99re热精品视频 | 在线第一页 | 欧美三级电影在线播放 | 欧美一区二区三区在线观看 | 我要看免费一级毛片 | 日韩一二区在线观看 | 午夜视频在线观看一区二区 | 欧美 日韩 国产 成人 | 国产精品久久视频 | 亚洲一二三区免费 | 欧产日产国产精品视频 | 日本免费一区二区三区 | 久久免费观看视频 | 一a一片一级一片啪啪 | 成人欧美一区二区三区在线播放 | 黄色三级毛片 | 曰批视频在线观看 | 免费观看的av毛片的网站 | 成人综合视频在线 | 日本电影韩国电影免费观看 | 中文字幕在线观看视频一区 | 欧美激情精品久久久久久免费 | 狠狠色狠狠色综合系列 | 九色在线| 男女视频免费 | 三级黄色大片网站 | 天天干在线播放 | 久久久国产一区二区三区 | 亚洲综合色视频在线观看 | 日韩一区二区在线免费观看 | 第四色播日韩第一页 | 久久精品国产亚洲一区二区 | 超碰精品在线 | 99精品视频一区二区三区 | 在线免费观看黄色av | 中文字幕综合 | 99久久免费精品国产免费高清 |