使用 ant 构建 Android 测试时如何使用 emma 过滤器?

发布于 2024-12-04 06:50:51 字数 175 浏览 4 评论 0原文

我知道在构建 Android 测试项目时如何在 ant 中使用 emma,但在使用 SDK 时找不到任何有关如何使用过滤器的提示。 emma 网站在自己调用 emma 时对此进行了解释,但在 Android SDK 构建文件中 emma 并未在 ant 文件或命令行中调用,因此我无法添加过滤器选项。

有人有什么建议吗?

I know how to use emma in ant when building my android test project but I can't find any tips on how to use filters when using the SDK. The emma website explains it when calling emma yourself but in the Android SDK build files emma is not called in the ant files or on the commandline so I'm not able to add the filter options.

Anyone any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘿哥们儿 2024-12-11 06:50:51

从 SDK Tools r18 开始,您只需添加

emma.filter=-com.your.excluded.package.*

到项目的 ant.properties(不是测试项目

As of SDK Tools r18 you can simply add

emma.filter=-com.your.excluded.package.*

to the ant.properties of your project (not Test project)

难理解 2024-12-11 06:50:51

这取决于您使用的 SDK 版本,特别是 /tools/ant 目录中包含的构建文件。

Android SDK >= 18

从 SDK r18 及更高版本开始,只需将属性添加到目标(非测试)项目的 ant.properties 文件即可。例如,使用

emma.filter=-*.test.*

从测试包中排除所有类。您可以在 emma 文档 中找到 emma 过滤器语法。

Android SDK< 18

此问题存在问题。它涉及以下内容:

  • 您必须修改目标项目(而不是测试项目)的构建文件,
  • 通过从导入的 android 构建中复制粘贴 -emma-instrument 目标来修改构建文件文件(您应该在通过运行 android create/update project 获得的标准项目构建文件中找到此方法的说明)
  • 根据链接的问题修改目标,它会看起来像:

    <目标名称=“-emma-instrument”取决于=“编译”>
        从 ${out.absolute.dir}/classes... 检测类...
        
        <艾玛启用=“true”>
            <指令详细程度=“trace1”
                   模式=“覆盖”
                   instrpath="${out.absolute.dir}/classes"
                   outdir="${out.absolute.dir}/classes">
                <过滤排除=“*.R,*.R$*,${emma.exclusion.pattern}”/>
            
            
        
    
    
  • 排除过滤器语法的解释可在 emma 文档

  • 要么修改修改,要么使用建议的 ant 属性 emma.exclusion.pattern< /code> 提供您自己的排除项

对我来说,这在 SDK 工具 r13 上就像一个魅力。

It depends on the SDK version you are using, specifically the included build files found in <android-sdk>/tools/ant directory.

Android SDK >= 18

As of the SDK r18 and above it's as simple as adding a property to your ant.properties file of the target (not test) project. So for example use

emma.filter=-*.test.*

To exlude all classes from a test package. You can find the emma filter syntax in the emma documentation.

Android SDK < 18

There's an issue for this. It involves the following:

  • you have to modify the build file for your target project (not the test project)
  • modify the build file by copy'n'pasting the -emma-instrument target from the imported android build files (you should find an explanation of this method in the standard project build file which you get by running android create/update project)
  • modify the target according to the linked issue, it'll look like:

    <target name="-emma-instrument" depends="compile">
        <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
        <!-- It only instruments class files, not any external libs -->
        <emma enabled="true">
            <instr verbosity="trace1"
                   mode="overwrite"
                   instrpath="${out.absolute.dir}/classes"
                   outdir="${out.absolute.dir}/classes">
                <filter excludes="*.R,*.R$*,${emma.exclusion.pattern}" />
            </instr>
            <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
                 user defined file -->
        </emma>
    </target>
    
  • an explanation of the exclusion filter syntax is available on the emma documentation

  • either modify the modification or use the proposed ant property emma.exclusion.pattern to provide your own exclusions

For me this has worked like a charm on SDK tools r13.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文