Android Firebase测试实验室不接受coverageFile环境变量
我用CircleCi让Firebase测试实验室为我运行仪器测试。所有测试都运行良好,据我所知,我已经正确设置了所有内容。然而,我真的很想得到我的代码覆盖率 SD卡从不包含代码覆盖率文件,在所有日志中,我发现了一个例外,我怀疑这就是问题所在:Android Firebase测试实验室不接受coverageFile环境变量,android,android-testing,firebase-test-lab,circleci-2.0,Android,Android Testing,Firebase Test Lab,Circleci 2.0,我用CircleCi让Firebase测试实验室为我运行仪器测试。所有测试都运行良好,据我所知,我已经正确设置了所有内容。然而,我真的很想得到我的代码覆盖率 SD卡从不包含代码覆盖率文件,在所有日志中,我发现了一个例外,我怀疑这就是问题所在: java.io.FileNotFoundException: /jacoco.exec (Read-only file system) at java.io.FileOutputStream.open0(Native Method)
java.io.FileNotFoundException: /jacoco.exec (Read-only file system)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:287)
at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.openFile(FileOutput.java:67)
at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.startup(FileOutput.java:49)
at org.jacoco.agent.rt.internal_8ff85ea.Agent.startup(Agent.java:122)
at org.jacoco.agent.rt.internal_8ff85ea.Agent.getInstance(Agent.java:50)
at org.jacoco.agent.rt.internal_8ff85ea.Offline.<clinit>(Offline.java:31)
at org.jacoco.agent.rt.internal_8ff85ea.Offline.getProbes(Offline.java:51)
at com.acme.android.MyApplication.$jacocoInit(Unknown Source:13)
at com.acme.android.MyApplication.<clinit>(Unknown Source:0)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newApplication(Instrumentation.java:1101)
at android.app.Instrumentation.newApplication(Instrumentation.java:1086)
at android.app.LoadedApk.makeApplication(LoadedApk.java:942)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5765)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
这就是我获取应该包含覆盖率文件的工件的方式:
- run:
name: Download instrumented test results from Firebase Test Lab
command: gsutil -m cp -r -U "`gsutil ls gs://test-lab-XXXXXX-YYYYY | tail -1`*" /root/workspace/firebase/ || true
我还确认覆盖率文件没有作为工件存储在Firebase中
我的gradle文件启用了代码覆盖率:
buildTypes {
debug {
matchingFallbacks = ["prod"]
minifyEnabled false
debuggable true
versionNameSuffix '-DEBUG'
testCoverageEnabled true
}
jacoco似乎默认使用根文件夹,并且在尝试在那里写入覆盖率文件时,Android文件系统拒绝了其权限。任何帮助都将不胜感激
谢谢,我在这里找到了答案:
问题是覆盖率文件的路径。它应该是/sdcard/coverage.ec
而不是/sdcard/tempDir/coverage.ec
。结果是tempDir
不存在,因此尝试写入该文件夹时失败
这是起作用的环境变量选项:
--环境变量coverage=true,coverage文件=“/sdcard/coverage.ec
你检查过谷歌示例应用程序的build.gradle吗?它有一些关于Jacoco测试覆盖率的参考资料,也许可以帮助您找到配置的问题所在,并检查@MatPag,感谢您通过这些检查。您引用的脚本似乎与代码覆盖率无关。github.gradle文件与我的文件几乎相同。我可能应该提到,当我在本地运行检测测试时,我可以生成代码覆盖率报告。我的问题似乎特定于在测试实验室中运行。如果使用启用orchestrator使用--使用orchestrator
,请参阅此
buildTypes {
debug {
matchingFallbacks = ["prod"]
minifyEnabled false
debuggable true
versionNameSuffix '-DEBUG'
testCoverageEnabled true
}