sbt-jacoco
sbt-jacoco copied to clipboard
Branch coverage for a simple case class is very low
package cpf.branch.coverage
trait Result
case class OKResult[A](a: A) extends Result
case class FailureResult(msg: String) extends Result
the code is like the above. when I run jacoco:cover, the result says: all 16 branches missed for the FailureResult case class.
and the pattern match code that uses the case class is like this:
...... match {
case OKResult(result) => result.toString
case FailureResult(error) => error
}
and the results says that 1 of 2 branches missed for the second case.
is this because scala compiler generates extra code that has more branches than I intended in the scala code? and how to work around this to make my branch coverage look normal?
the code above is here: https://github.com/cuipengfei/reproduce-weird-issues/tree/master/scala-jacoco-branch-coverage