Skip to content

Commit

Permalink
Add Codecov integration with Travis CI
Browse files Browse the repository at this point in the history
Generate code coverage for instrumentation tests
Update Jacoco to 0.7.6.201602180812
  • Loading branch information
artem-zinnatullin committed Mar 15, 2016
1 parent 802d80e commit 3e69f89
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ android:
- extra-android-support
- sys-img-armeabi-v7a-android-18

before_install:
- pip install --user codecov

before_script:
- echo no | android create avd --force -n test -t android-18 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
Expand All @@ -22,6 +25,9 @@ before_script:

script:
- sh ci.sh

after_success:
- codecov

notifications:
email: true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ What does it have:
* Integration tests to see that Http, REST, JSON parsing and RxJava work well in composition.
* Functional (UI) tests (Espresso with custom rules, mocked server and Screen-architecture) to check that app works according to the expectations from the user's point of view.
* Static code analysis (FindBugs, PMD, Android Lint, Checkstyle) (see root `build.gradle`).
* Code coverage (currently in process of fighting with jacoco-coverage plugin to fail the build if coverage is not big enough).
* Code coverage [![codecov.io](https://codecov.io/github/artem-zinnatullin/qualitymatters/coverage.svg?branch=master)](https://codecov.io/github/artem-zinnatullin/qualitymatters?branch=master)
* Developer Settings Menu where you can enable/disable [Stetho](http://facebook.github.io/stetho/), [LeakCanary](https://github.com/square/leakcanary), etc. See full list below (feel free to add more tools!).
* Git sha & build time without breaking incremental compilation! (Thanks to [Paperwork](https://github.com/zsoltk/paperwork))
* MVP, RxJava, Dagger 2, Retrofit 2 and so on.
Expand Down
9 changes: 8 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ android {
debug {
signingConfig signingConfigs.qualityMatters
applicationIdSuffix '.debug'

// Enables code coverage with Jacoco only for instrumentation tests.
// Coverage for JVM tests done by code_quality_tools/jacoco.gradle.
testCoverageEnabled true
}

release {
signingConfig signingConfigs.qualityMatters

minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt')

// Enables code coverage with Jacoco only for instrumentation tests.
// Coverage for JVM tests done by code_quality_tools/jacoco.gradle.
testCoverageEnabled true
}
}

Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ buildscript {
// Generates build info without breaking incremental builds
classpath libraries.paperworkPlugin

// Code coverage.
classpath 'org.jacoco:org.jacoco.core:0.7.6.201602180812'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
9 changes: 4 additions & 5 deletions code_quality_tools/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// https://github.com/mgouline/android-samples/blob/master/jacoco/app/build.gradle
// and https://github.com/pushtorefresh/storio/blob/master/gradle/jacoco-android.gradle

// Requires Jacoco plugin in build classpath.
apply plugin: 'jacoco'

jacoco {
// See https://github.com/jacoco/jacoco/releases
toolVersion = '0.7.5.201505241946'
}

// Enables code coverage for JVM tests.
// Android Gradle Plugin out of the box supports only code coverage for instrumentation tests.
project.afterEvaluate {
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
Expand Down Expand Up @@ -54,6 +52,7 @@ project.afterEvaluate {
"src/$productFlavorName/java",
"src/$buildTypeName/java"
]

additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")
Expand Down

0 comments on commit 3e69f89

Please sign in to comment.