我试图让使用Jacoco手工测试code覆盖。我想使用离线仪器仪表。 http://www.eclemma.org/jacoco/trunk/doc/offline.html
I am trying to get code coverage using Jacoco for manual testing. I am trying to use offline instrumentation. http://www.eclemma.org/jacoco/trunk/doc/offline.html
在那里提到:
配置文件:如果一个文件 jacoco-agent.properties
的类路径选项提供从该文件中加载
In there it mentions:
Configuration File: If a file jacoco-agent.properties
is supplied on the classpath options are loaded from this file.
我的问题是我怎么提供呢?在其他一些论坛上,我看到 jacoco-agent.properties
需要部署的应用程序。
My question is how do I supply this? On some other forum, I saw that jacoco-agent.properties
needs to be deployed with the app.
我试图把 jacoco-agent.properties
下RES /生,但抱怨 - 在文件名中。
I tried putting jacoco-agent.properties
under the res/raw, but it complained about "-" in the file name.
我试图把这个根目录下并没有采取任何的影响下。
I tried putting this under the root directory it didn't take any effect.
我不知道我怎么会设置\运行jacoco,以便它使用 jacoco-agent.properties
?
I was wondering how could I setup\run jacoco so that it uses jacoco-agent.properties
?
嗯,至少一个Ant的命令行构建的伎俩是把 jacoco-agent.properties
在的src
目录,这使得它获得打包为-是到APK文件的根,从那里似乎是正确读取(即我可以看到设置 destfile
属性具有在哪里被创建的执行数据文件产生影响)。
Well, at least for an Ant command line build the trick was to put jacoco-agent.properties
in the src
directory, which makes it get packaged as-is into the root of the APK file, from where it seems to be properly read (i.e. I can see setting the destfile
property having an effect on where the execution data file is being created).
然而,创建 jacoco.exec
文件总是空的,我(像也提到的此处),可能是因为JaCoCo只写了执行数据的在JVM终止,但是当应用程序停止Android的Dalvik虚拟机不会终止。
However, the created jacoco.exec
file was always empty for me (like also mentioned here), probably because JaCoCo only writes the execution data at JVM termination, but Android's Dalvik VM does not terminate when the app stops.
我们目前解决这个问题的方法是显式调用
The way we currently solve this is to explicitly call
org.jacoco.agent.rt.RT.getAgent().getExecutionData(false)
和写回的字节数组到一个文件时,我们自定义的测试运行结束。
and write the returned byte array to a file when our custom test runner finishes.