Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Jacoco #33

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -14,7 +15,9 @@
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleInstrumentedTest {

@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Expand Down
4 changes: 4 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
-keepattributes *Annotation*
-keep class javax.inject.** { *; }

# OkHttp
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.OpenSSLProvider

# Retrofit 2.X
## https://square.github.io/retrofit/ ##
-dontnote retrofit2.Platform
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "com.android.tools.build:gradle:${Versions.gradleVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlinVersion}"
classpath 'org.jacoco:org.jacoco.core:0.8.1'
}
}

Expand Down
22 changes: 13 additions & 9 deletions buildSrc/src/main/java/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Deps {
val cardView = "com.android.support:cardview-v7:$supportLibraryVersion"
val customtabs = "com.android.support:customtabs:$supportLibraryVersion"
val constraintLayout = "com.android.support.constraint:constraint-layout:1.1.0-beta5"
val multidex = "com.android.support:multidex:1.0.2"
val multidex = "com.android.support:multidex:1.0.3"

// Firebase
val firebaseConfig = "com.google.firebase:firebase-config:$playVersion"
Expand All @@ -43,7 +43,7 @@ object Deps {
// Api
val retrofit = "com.squareup.retrofit2:retrofit:$retrofitVersion"
val moshi = "com.squareup.moshi:moshi-kotlin:1.5.0"
val converterMoshi = "com.squareup.retrofit2:converter-moshi:2.3.0"
val converterMoshi = "com.squareup.retrofit2:converter-moshi:$retrofitVersion"
val adapterRxjava = "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
val okhttp = "com.squareup.okhttp3:okhttp:$okhttpVersion"
val loggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
Expand All @@ -66,12 +66,12 @@ object Deps {
val rxbindingRecyclerview = "$rxbindingGroupId:rxbinding-recyclerview-v7:$rxbindingVersion"

// Libraries
val picasso = "com.squareup.picasso:picasso:2.6.0-SNAPSHOT"
val picasso = "com.squareup.picasso:picasso:2.71828"
val rxjava = "io.reactivex.rxjava2:rxjava:$rxjavaVersion"
val rxandroid = "io.reactivex.rxjava2:rxandroid:$rxandroidVersion"
val patrons = "com.prolificinteractive:patrons:0.1.0"
val conceal = "com.facebook.conceal:conceal:2.0.2@aar"
val timber = "com.jakewharton.timber:timber:4.6.1"
val timber = "com.jakewharton.timber:timber:4.7.0"
val chuck = "com.readystatesoftware.chuck:library:$chuckVersion"
val chuckNoOp = "com.readystatesoftware.chuck:library-no-op:$chuckVersion"
val threetenabp = "com.jakewharton.threetenabp:threetenabp:1.0.5"
Expand All @@ -82,8 +82,9 @@ object Deps {

// Testing
val jUnit = "junit:junit:$junitVersion"
val mockito = "org.mockito:mockito-core:2.15.0"
val mockito = "org.mockito:mockito-core:2.17.0"
val hamcrest = "org.hamcrest:hamcrest-all:1.3"
val robolectric = "org.robolectric:robolectric:3.8"

// Dependency Group
val rx = listOf(rxjava, rxandroid)
Expand All @@ -103,13 +104,15 @@ object Deps {
okhttp,
loggingInterceptor,
okio,
moshi)
moshi
)

val arch = listOf(archEx, archJava, archRuntime)

val archAP = listOf(archCompiler)

val supportLibs = listOf(appcompatV7,
val supportLibs = listOf(
appcompatV7,
cardView,
constraintLayout,
customtabs,
Expand All @@ -125,9 +128,10 @@ object Deps {
firebaseCore,
firebaseCrash,
firebasePerf,
firebaseMessaging)
firebaseMessaging
)

val testLibs = listOf(jUnit, mockito, hamcrest)
val testLibs = listOf(jUnit, mockito, hamcrest, robolectric)

val featureProjects = listOf(":auth", ":home", ":show")
}
10 changes: 5 additions & 5 deletions buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ object Versions {
const val targetSdkVersion = 27
const val buildToolsVersion = "27.0.2"
const val gradleVersion = "3.0.1"
const val kotlinVersion = "1.2.30"
const val kotlinVersion = "1.2.31"

// Libraries Version
const val archVersion = "1.1.0"
const val chuckVersion = "1.1.0"
const val daggerVersion = "2.14.1"
const val daggerVersion = "2.15"
const val junitVersion = "4.12"
const val leakCanaryVersion = "1.5.4"
const val okhttpVersion = "3.10.0"
const val playVersion = "11.8.0"
const val retrofitVersion = "2.3.0"
const val playVersion = "12.0.1"
const val retrofitVersion = "2.4.0"
const val rxandroidVersion = "2.0.2"
const val rxbindingVersion = "2.1.1"
const val rxjavaVersion = "2.1.10"
const val rxjavaVersion = "2.1.12"
const val supportLibraryVersion = "27.1.0"
}
2 changes: 1 addition & 1 deletion home/build.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
apply from: rootProject.file('feature.gradle')
apply from: rootProject.file('feature.gradle')
43 changes: 43 additions & 0 deletions jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'jacoco'

jacoco {
toolVersion = '0.8.1'
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}

task jacocoTestReport(type: JacocoReport,
dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {

reports {
xml.enabled = true
html.enabled = true
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*', '**/*$[0-9].*']
def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
def mainSrc = "$project.projectDir/src/main/java"

sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: project.buildDir,
includes: ['jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'])
}

android {
buildTypes {
debug {
testCoverageEnabled true
}
}
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
animationsDisabled true

unitTests {
includeAndroidResources = true
}
}
}
5 changes: 5 additions & 0 deletions module.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: rootProject.file('jacoco.gradle')

androidExtensions.experimental = true

Expand Down Expand Up @@ -72,6 +73,10 @@ dependencies {

Deps.testLibs.each { testImplementation it }

testImplementation 'org.robolectric:robolectric:3.8'
androidTestImplementation Deps.supportAnnotations
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestUtil 'com.android.support.test:orchestrator:1.0.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
Expand Down