I am following these two links 1 and 2 for espresso test report but getting error while running ./gradlew createDebugCoverageReport
. The error will be shown in image given below. Please help me, I am not able to generated report for espresso and ui automation test cases. Now trying to use jacoco
but not able to find any solution.
Build.Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example.project"
minSdkVersion 18
targetSdkVersion 24
versionCode 27
versionName "1.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testCoverageEnabled true
}
debug{
testCoverageEnabled true
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.github.barteksc:android-pdf-viewer:2.0.3'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-annotations:24.2.0'
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.0'
androidTestCompile 'com.android.support:support-annotations:24.2.1'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-v7'
exclude group: 'com.android.support', module: 'design'
exclude module: 'support-annotations'
exclude module: 'recyclerview-v7'
}
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile "com.android.support.test.espresso:espresso-intents:2.2.2"
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'jacoco'
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: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec",
"outputs/code-coverage/connected/*coverage.ec"
])
}
A few things that got this running: