square / spoon

Distributing instrumentation tests to all your Androids.
https://square.github.io/spoon/
Apache License 2.0
2.7k stars 476 forks source link

Can't create coverage.ec files,please help #530

Closed yxcSini closed 6 years ago

yxcSini commented 6 years ago

Use Jar: runner-1.7.1.jar

Command: java -jar spoon-runner-1.7.1.jar --apk ps_lib-tests-debug.apk --test-apk ps_lib-tests-debug-androidTest.apk --grant-all --coverage true

build.gradle:

apply plugin: 'jacoco'
 buildTypes {
        debug {
            testCoverageEnabled true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    } 
jacoco{
    toolVersion = "0.7.1.201405082137"
}

log:

2018-04-24 10:49:42 [SR.runTests] Executing instrumentation suite on 3 device(s).
Exception in thread "main" java.lang.RuntimeException: Error while merging coverage files. Did you set the "testCoverageEnabled" flag in your build.gradle?
    at com.squareup.spoon.SpoonRunner.run(SpoonRunner.java:141)
    at com.squareup.spoon.SpoonRunner.main(SpoonRunner.java:695)
Caused by: java.io.FileNotFoundException: spoon-output\coverage\emulator-5556\coverage.ec 
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.jacoco.core.tools.ExecFileLoader.load(ExecFileLoader.java:71)
    at com.squareup.spoon.SpoonCoverageMerger.mergeCoverageFiles(SpoonCoverageMerger.java:28)
    at com.squareup.spoon.SpoonRunner.run(SpoonRunner.java:138)
    ... 1 more

Problem: I use command gradle clean createDebugCoverageReport,it can create coverage.ec files. And I use the same apk file to spoon, it not works. image