diff --git a/.travis.yml b/.travis.yml index f84dcdf290e..984c71ab1d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,10 @@ script: # - ./gradlew :owncloudApp:installDebugAndroidTest # run sample instrumented unit test # - adb shell am instrument -w -e debug false -e class com.owncloud.android.datamodel.OCFileUnitTest com.owncloud.android.test/android.support.test.runner.AndroidJUnitRunner +# run the jacoco test report on Travis +- if [ -e ./gradlew ]; then ./gradlew jacocoTestReport;else gradle jacocoTestReport;fi +# upload the test coverage to Travis. +- bash <(curl -s https://codecov.io/bash) env: global: - secure: h4Y7ZvgbvOj5T71ubRcw3Fy3KXF8qHugRFLGK3q2R9YuRsDAf8XH+Y/UiXyH8sac2QSj7Zlny1kA1DEJgwhTXs9wsAVKVJCQNTJGEvhm/4uQgPeNMzMv07Lqe8V+KUBsFH5qhfPJO357ERW0k2f2qljoLSHtHStclt7iGvFdynA= diff --git a/owncloudApp/build.gradle b/owncloudApp/build.gradle index bd3eb649dee..3be706463cd 100644 --- a/owncloudApp/build.gradle +++ b/owncloudApp/build.gradle @@ -1,5 +1,31 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'jacoco' + +jacoco { + toolVersion = "0.7.6.201602180812" +} + +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/**/*.*'] + def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter) + def mainSrc = "$project.projectDir/src/main/java" + + sourceDirectories = files([mainSrc]) + classDirectories = files([debugTree]) + +} def commitSHA1 = 'COMMIT_SHA1' def gitRemote = 'GIT_REMOTE' @@ -121,6 +147,7 @@ android { debug { applicationIdSuffix ".debug" + testCoverageEnabled true } }