mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-08-13 15:53:53 -04:00
Jacoco support for local unit tests
This commit is contained in:
parent
7a5121894e
commit
b856d82ae2
@ -1,5 +1,6 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'witness'
|
apply plugin: 'witness'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
|
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
|
||||||
@ -136,6 +137,10 @@ android {
|
|||||||
|
|
||||||
// Reference them in .xml files.
|
// Reference them in .xml files.
|
||||||
resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account"
|
resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account"
|
||||||
|
|
||||||
|
// Disabled: only works for androidTest not test!
|
||||||
|
// Enable code coverage (Jacoco)
|
||||||
|
//testCoverageEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,6 +193,32 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task jacocoTestReport(type:JacocoReport) {
|
||||||
|
group = "Reporting"
|
||||||
|
description = "Generate Jacoco coverage reports"
|
||||||
|
|
||||||
|
classDirectories = fileTree(
|
||||||
|
dir: "${buildDir}/intermediates/classes/debug",
|
||||||
|
excludes: ['**/R.class',
|
||||||
|
'**/R$*.class',
|
||||||
|
'**/*$ViewInjector*.*',
|
||||||
|
'**/BuildConfig.*',
|
||||||
|
'**/Manifest*.*']
|
||||||
|
)
|
||||||
|
|
||||||
|
sourceDirectories = files("${buildDir.parent}/src/main/java")
|
||||||
|
additionalSourceDirs = files([
|
||||||
|
"${buildDir}/generated/source/buildConfig/debug",
|
||||||
|
"${buildDir}/generated/source/r/debug"
|
||||||
|
])
|
||||||
|
executionData = files("${buildDir}/jacoco/testDebug.exec")
|
||||||
|
|
||||||
|
reports {
|
||||||
|
xml.enabled = true
|
||||||
|
html.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: This disables Lint!
|
// NOTE: This disables Lint!
|
||||||
tasks.whenTaskAdded { task ->
|
tasks.whenTaskAdded { task ->
|
||||||
if (task.name.contains('lint')) {
|
if (task.name.contains('lint')) {
|
||||||
|
@ -51,8 +51,12 @@ Select everything for the newest SDK Platform, API 22, and also API 21
|
|||||||
|
|
||||||
### Run Tests
|
### Run Tests
|
||||||
1. Use OpenJDK instead of Oracle JDK
|
1. Use OpenJDK instead of Oracle JDK
|
||||||
2. Execute ``./gradlew clean``
|
2. Execute ``./gradlew clean testDebug --continue``
|
||||||
3. Execute ``./gradlew testDebug --continue``
|
|
||||||
|
### Run Jacoco Test Coverage
|
||||||
|
1. Use OpenJDK instead of Oracle JDK
|
||||||
|
2. Execute ``./gradlew clean testDebug jacocoTestReport``
|
||||||
|
3. Report is here: OpenKeychain/build/reports/jacoco/jacocoTestReport/html/index.html
|
||||||
|
|
||||||
### Development with Android Studio
|
### Development with Android Studio
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user