Partial EMMA code coverage in Scala Case Class for IntelliJ IDEA 10.5
case class A(a: Any)
generate a number of methods for you, among them:
A#equals
A#canEqual
A#hashCode
A#toString
A#productPrefix
A#productElement
A#productArity
A#productIterator
A#copy
A.unapply
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.
I know this is a very old question, but the problem still stands today to some extent. Given a simple case class, in order to get a full coverage report from IntelliJ you need to test the unapply
method as well.
// Code
final case class Foo(symbol: String, name: String)
// Test
val myFoo = Foo("TheSymbol", "TheName")
Foo.unapply(myFoo).get should be(("TheSymbol", "TheName"))
Without it I got 50% coverage for a basic case class like that.