Create coverage report for instrumented tests where the source lives in other modules

This commit is contained in:
Sean Mac Gillicuddy 2019-10-18 11:54:31 +01:00
parent af3ef4cf63
commit 1033a9a45f
7 changed files with 69 additions and 7 deletions

View File

@ -52,7 +52,7 @@ before_script:
- adb shell input keyevent 82 &
script:
- ./gradlew createDebugCoverageReport ktlintCheck lint jacocoTestReport app:assembleRelease
- ./gradlew jacocoInstrumentationTestReport ktlintCheck lint jacocoTestReport app:assembleRelease
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -7,6 +7,8 @@ plugins {
}
apply plugin: KiwixConfigurationPlugin
apply from: rootProject.file("jacoco.gradle")
ext {
versionMajor = 3
versionMinor = 0

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.data.local.dao;/*
package org.kiwix.kiwixmobile.data.local.dao;
import android.content.Context;
import androidx.test.InstrumentationRegistry;

View File

@ -16,7 +16,7 @@
*
*/
package org.kiwix.kiwixmobile.data.local.dao;/*
package org.kiwix.kiwixmobile.data.local.dao;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.yahoo.squidb.data.AbstractModel;

View File

@ -19,7 +19,6 @@ apply plugin: 'io.objectbox'
apply plugin: 'com.jakewharton.butterknife'
android {
publishNonDefault true
buildTypes {
release {
minifyEnabled false

View File

@ -31,6 +31,7 @@ import kotlinx.android.synthetic.main.item_book.item_book_label_picture
import kotlinx.android.synthetic.main.item_book.item_book_label_video
import kotlinx.android.synthetic.main.item_book.item_book_size
import kotlinx.android.synthetic.main.item_book.item_book_title
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
import org.kiwix.kiwixmobile.core.downloader.model.Base64String
import org.kiwix.kiwixmobile.core.extensions.setBitmap
import org.kiwix.kiwixmobile.core.main.KiwixWebView
@ -42,7 +43,6 @@ import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.MULT
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode.NORMAL
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.LanguageItem
import org.kiwix.kiwixmobile.core.base.adapter.BaseViewHolder
sealed class BookOnDiskViewHolder<in T : BooksOnDiskListItem>(containerView: View) :
BaseViewHolder<T>(containerView) {
@ -76,8 +76,8 @@ sealed class BookOnDiskViewHolder<in T : BooksOnDiskListItem>(containerView: Vie
if (sharedPreferenceUtil.nightMode()) {
item_book_icon.drawable
.mutate()
.colorFilter = ColorMatrixColorFilter(KiwixWebView.NIGHT_MODE_COLORS)
?.mutate()
?.colorFilter = ColorMatrixColorFilter(KiwixWebView.NIGHT_MODE_COLORS)
}
val path = item.file.path

61
jacoco.gradle Normal file
View File

@ -0,0 +1,61 @@
/*
* Kiwix Android
* Copyright (c) 2019 Kiwix <android.kiwix.org>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.3"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
task jacocoInstrumentationTestReport(type: JacocoReport, dependsOn: ['createDebugCoverageReport']) {
group "Reporting"
description "Generate Jacoco coverage reports."
reports {
xml.enabled = true
html.enabled = true
html.destination file("${rootProject.buildDir}/coverage-report")
}
def javaClasses = []
def kotlinClasses = []
def javaSrc = []
def kotlinSrc = []
def execution = []
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
rootProject.subprojects.each { proj ->
javaClasses << fileTree(dir: "$proj.buildDir/intermediates/javac/debug", excludes: fileFilter)
kotlinClasses << fileTree(dir: "$proj.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
javaSrc << "$proj.projectDir/src/main/java"
kotlinSrc << "$proj.projectDir/src/main/kotlin"
execution << fileTree(dir: proj.buildDir,
includes: ['jacoco/testDebugUnitTest.exec',
'outputs/code_coverage/debugAndroidTest/connected/**/*.ec'])
}
sourceDirectories = files([javaSrc, kotlinSrc])
classDirectories = files([javaClasses, kotlinClasses])
print execution
executionData = files(execution)
doLast() {
print "file://${reports.html.destination}/index.html"
}
}