包装jacoco-agent.properties成一个APK因此它可以被读取? [英] packaging jacoco-agent.properties into an APK so it can be read?

查看:2029
本文介绍了包装jacoco-agent.properties成一个APK因此它可以被读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的情况:

背景


  • 我调查code-覆盖我们的Andr​​oid应用程序。这个应用程序是建立与摇篮和Android工作室。

  • 我需要在两种情况下code-覆盖报告:在手动测试,并在我们的庞大Appium套件内置自动化测试。

  • 我需要证明的概念出来的快速的(是不是总是这样?),所以我还没有做彻底的R&AMP中的机会; d。所以请原谅我显示任何的无知:)

  • 我可以访问应用程序的来源,但有运动部件的小知识。

  • 我已经调查JaCoCo和艾玛。这个问题涉及JaCoCo。

  • 鉴于我们需要覆盖Appium和手动测试,我相信离线仪器仪表与JaCoCo正是我需要的。

  • I am investigating code-coverage for our Android app. The app is built with Gradle and Android Studio.
  • I need code-coverage reports in two situations: during manual tests, and during automated tests built with our sizeable Appium suite.
  • I need to get a proof-of-concept out fast (isn't that always the case?) so I haven't had the chance to do thorough R&D. So please forgive any ignorance I display :)
  • I have access to the app source, but have little knowledge of the moving parts.
  • I have investigated JaCoCo and Emma. This question pertains to JaCoCo.
  • Given that we need coverage for Appium and manual tests, I believe offline-instrumentation with JaCoCo is what I need.

进展情况


  • 我用的JaCoCo插件页面和的 Android的工具页面并能正确配置的build.gradle。

  • 我已经验证了类(在 present建立\\中间体\\班)与JaCoCo被监测,并打包在APK。

  • 我写的每一个BroadcastReceiver <一个href=\"http://stackoverflow.com/questions/30976319/android-gradle-jacoco-offline-instrumentation-for-integration-tests\">this SO讨论,将收到末覆盖播出。

  • I used the JaCoCo plugin page and the Android Tools page and could configure build.gradle properly.
  • I have verified that the classes (present in build\intermediates\classes) are instrumented with JaCoCo, and are packaged in the APK.
  • I wrote a BroadCastReceiver per this SO discussion, which will receive the "end coverage" broadcast.

问题

当我手动运行该应用程序,我不断看到错误的logcat中
    W / System.err的:java.io.FileNotFoundException:/jacoco.exec:打开失败:EROFS(只读文件系统)

When I run the app manually, I keep seeing errors in the logcat W/System.err: java.io.FileNotFoundException: /jacoco.exec: open failed: EROFS (Read-only file system)

SO质疑和<一个HREF =htt​​p://eclemma.org/jacoco/trunk/doc/offline.html相对=nofollow>的JaCoCo文档我明白Jacoco需要知道在哪里存储 jacoco.exec 文件 - 和我需要打包jacoco-agent.properties(含 destfile 属性)的APK。

From this SO question and the JaCoCo docs I understand that Jacoco needs to know where to store the jacoco.exec file - and that I need to package a jacoco-agent.properties (containing a destfile property) with the APK.

我试图把jacoco-agent.properties在资产 - 它被打包成APK正常,但似乎没有任何效果(即Jacoco未能像往常一样)
我试图把它 RES 里面 - 它没有得到打包成APK。
我试图 RES /原料并击中了错误有关的文件名一个破折号,如的这太问题

I have tried putting jacoco-agent.properties in assets - it was packaged into the APK properly, but did not seem to have any effect (i.e Jacoco failed as usual) I tried putting it inside res - it did not get packaged into the APK. I tried res/raw and hit the error about a dash in the filename, as in this SO question.

我在我束手无策,而且会真正AP preciate帮助。我应如何包装jacoco-agent.properties用我的摇篮打造成了APK,使JaCoCo会读吗?

I am at my wit's end, and would really appreciate help. How do I package jacoco-agent.properties using my Gradle build into the APK, so that JaCoCo will read it?

相关问题

这太问题,有一个答案从2013年开始,它是为Ant,没有摇篮。

this SO question, has an answer from 2013, and it's for Ant, not Gradle.

推荐答案

我不熟悉执行 Jacoco 工作的要求,但你可以用打包的文件在APK pretty容易。下面code将会把 jacoco-agent.properties 在您的apk包的根。

I'm not familiar with the requirement for executing Jacoco working, but you can package a file with the apk pretty easily. The below code will place the jacoco-agent.properties at the root of your apk package.

请这些更改的build.gradle 为您的应用程序模块:

Make these changes to the build.gradle for your app module:

android {
    ...
    sourceSets {
        main {
            resources.includes = [ '**/jacoco-agent.properties' ]
        }       
    }
}

这篇关于包装jacoco-agent.properties成一个APK因此它可以被读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆