diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..e8f736e --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,38 @@ +coverage: + precision: 2 + round: down + range: "30...45" + status: + patch: yes + changes: no + +comment: + layout: "header, diff, changes, tree" + behavior: default + +ignore: + - "tst/*" # ignore test harness code + - "tst/**/*" # ignore test harness code + - '**/R.class' + - '**/R$*.class' + - '**/BuildConfig.*' + - '**/Manifest*.*' + - '**/*Test*.*' + - 'android/**/*.*' + - '**/R2.class' + - '**/R2$*.class' + - '**/*_ViewBinding*.*' + - '**/*Dagger*Component*.*' + - '**/*Module.*' + - '**/*Module$*.*' + - '**/*Module_Proxy.*' + - '**/*MembersInjector*.*' + - '**/*_Factory*.*' + - '**/*Provide*Factory*.*' + - '**/*Factory.*' + - '**/*Activity.*' + - '**/App.class' + - '**/*Adapter.*' + - '**/*ViewHolder*.*' + - '**/api/response/*.*' + - '**/data/model/*.*' \ No newline at end of file diff --git a/.gitignore b/.gitignore index c88a4b6..e1dabdd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .DS_Store /build /captures +*.exec \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 6d57bbc..9e0c2cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -110,4 +110,6 @@ notifications: urls: - https://webhooks.gitter.im/e/1b633ac4f7ea6fa35dd1 on_success: change - on_failure: always \ No newline at end of file + on_failure: always +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/build.gradle b/build.gradle index 29b2077..d454a72 100644 --- a/build.gradle +++ b/build.gradle @@ -8,9 +8,17 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:3.5.3' + classpath 'org.jacoco:org.jacoco.core:0.8.5' + classpath 'org.neotech.plugin:android-root-coverage-plugin:1.2.0' } } + +apply plugin: 'jacoco' +jacoco { toolVersion = '0.8.5' } + +apply plugin: 'org.neotech.plugin.rootcoverage' + allprojects { repositories { jcenter() @@ -21,3 +29,49 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir } + +rootCoverage { + buildVariant "debug" +// buildVariantOverrides ":driver" : "mockDebug" + + // Class exclude patterns + excludes = [ + '**/R.class', + '**/R$*.class', + '**/BuildConfig.*', + '**/Manifest*.*', + '**/*Test*.*', + 'android/**/*.*', + + //Butterknife hack for multi-modules poroject + '**/R2.class', + '**/R2$*.class', + '**/*_ViewBinding*.*', + + //Dagger 2 + '**/*Dagger*Component*.*', + '**/*Module.*', + '**/*Module$*.*', + '**/*Module_Proxy.*', + '**/*MembersInjector*.*', + '**/*_Factory*.*', + '**/*Provide*Factory*.*', + + //Autofactory + '**/*Factory.*', + + //Classes I intentionally don't want to test + '**/*Activity.*', + '**/App.class', + '**/*Adapter.*', + '**/*ViewHolder*.*', + '**/api/response/*.*', + '**/data/model/*.*', + ] + executeTests true + executeAndroidTests false + executeUnitTests true + generateXml true + includeAndroidTestResults false + includeUnitTestResults true +} \ No newline at end of file diff --git a/data/build.gradle b/data/build.gradle index 4689f59..8947335 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -1,5 +1,5 @@ +apply plugin: 'com.android.library' apply from: "$rootDir/gradle/android_common.gradle" - dependencies { def dataDependencies = rootProject.ext.dataDependencies def dataTestDependencies = rootProject.ext.dataTestDependencies diff --git a/domain/build.gradle b/domain/build.gradle index bb1577c..e429204 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -1,3 +1,4 @@ +apply plugin: 'com.android.library' apply from: "$rootDir/gradle/android_common.gradle" dependencies { def domainDependencies = rootProject.ext.domainDependencies diff --git a/gradle/android_common.gradle b/gradle/android_common.gradle index 6d6525b..d6490d1 100644 --- a/gradle/android_common.gradle +++ b/gradle/android_common.gradle @@ -1,4 +1,5 @@ -apply plugin: 'com.android.library' +apply plugin: 'jacoco' +jacoco { toolVersion = '0.8.5' } android { compileSdkVersion rootProject.ext.androidCompileSdkVersion @@ -12,6 +13,9 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { + debug { + testCoverageEnabled true + } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' @@ -24,4 +28,12 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + + testOptions { + execution 'ANDROIDX_TEST_ORCHESTRATOR' + animationsDisabled true + unitTests { + includeAndroidResources = true + } + } } \ No newline at end of file diff --git a/presentation/build.gradle b/presentation/build.gradle index 121bbff..6733f7f 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -1,15 +1,8 @@ apply plugin: 'com.android.application' - +apply from: "$rootDir/gradle/android_common.gradle" android { - compileSdkVersion rootProject.ext.androidCompileSdkVersion - buildToolsVersion rootProject.ext.androidBuildToolsVersion - defaultConfig { applicationId 'com.jordifierro.androidbase.presentation' - minSdkVersion rootProject.ext.androidMinSdkVersion - targetSdkVersion rootProject.ext.androidTargetSdkVersion - versionCode rootProject.ext.appVersionCode - versionName rootProject.ext.appVersionName testInstrumentationRunner 'com.jordifierro.androidbase.presentation.TestMockerRunner' } compileOptions {