IntelliJ IDEA 10.5的Scala案例类中的部分EMMA代码覆盖率 [英] Partial EMMA code coverage in Scala Case Class for IntelliJ IDEA 10.5

查看:737
本文介绍了IntelliJ IDEA 10.5的Scala案例类中的部分EMMA代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IntelliJ IDEA 10.5与8月14日更新的Scala插件v0.4.1338和Scala 2.9.0.1。我最近开始在IDEA中使用EMMA测试覆盖实用程序生成覆盖率报告。

I'm using IntelliJ IDEA 10.5 with the Scala plugin v0.4.1338 updated on August 14th, and Scala 2.9.0.1. I recently began using the EMMA test coverage utility in IDEA to generate coverage reports.

我无法确定为什么我的Scala案例类的构造函数行只显示部分(黄色)覆盖。我查看了EMMA常见问题解答并在线研究了此事但没有成功。有没有人知道如何在案例类上达到100%的覆盖率?

I cannot determine why the constructor line of my Scala case class is only showing partial (yellow) coverage. I have looked in the EMMA FAQs and researched the matter online with no success. Does anyone have any idea how I can reach 100% coverage on a case class?

推荐答案

案例类A(a:Any)为您生成多种方法,其中包括:

case class A(a: Any) generate a number of methods for you, among them:


  1. A#equals

  2. A#canEqual

  3. A#hashCode

  4. A#toString

  5. A#productPrefix

  6. A#productElement

  7. A#productArity

  8. A#productIterator

  9. A#copy

  10. A.unapply

  11. A.apply

  1. A#equals
  2. A#canEqual
  3. A#hashCode
  4. A#toString
  5. A#productPrefix
  6. A#productElement
  7. A#productArity
  8. A#productIterator
  9. A#copy
  10. A.unapply
  11. A.apply

大多数这些将在字节码中以与类定义相同的行号报告。

Most of these will be reported in the bytecode at the same line number as the class definition.

您可以编写一个反射实用程序来调用所有这些每个单元的方法测试您的案例类,修补代码覆盖率工具以忽略该行,或者只是忍受它。

You could write a reflective utility to call all of these methods in each unit test for your case classes, patch the code coverage tool to ignore that line, or just put up with it.

这篇关于IntelliJ IDEA 10.5的Scala案例类中的部分EMMA代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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