@@ -27,6 +27,8 @@ import com.buransky.plugins.scoverage.xml.data.XmlReportFile1
2727import scala ._
2828import com .buransky .plugins .scoverage .{ProjectStatementCoverage , FileStatementCoverage , DirectoryStatementCoverage }
2929import com .buransky .plugins .scoverage .pathcleaner .PathSanitizer
30+ import com .buransky .plugins .scoverage .StatementCoverage
31+ import com .buransky .plugins .scoverage .NodeStatementCoverage
3032
3133@ RunWith (classOf [JUnitRunner ])
3234class XmlScoverageReportConstructingParserSpec extends FlatSpec with Matchers {
@@ -52,9 +54,16 @@ class XmlScoverageReportConstructingParserSpec extends FlatSpec with Matchers {
5254 assertReportFile(XmlReportFile1 .scoverage104Data, 50.0 , sanitizer) { projectCoverage =>
5355 assert(projectCoverage.name === " " )
5456 assert(projectCoverage.children.size.toInt === 1 )
57+
5558 projectCoverage.children.head match {
56- case rootDir : DirectoryStatementCoverage =>
57- assert(rootDir.name == " com" )
59+ case rootDir : DirectoryStatementCoverage => {
60+ val rr = checkNode(rootDir, " com" , 0 , 0 , 0.0 ).head
61+ val test = checkNode(rr, " rr" , 0 , 0 , 0.0 ).head
62+ val sonar = checkNode(test, " test" , 0 , 0 , 0.0 ).head
63+ val mainClass = checkNode(sonar, " sonar" , 2 , 1 , 50.0 ).head
64+
65+ checkNode(mainClass, " MainClass.scala" , 2 , 1 , 50.0 )
66+ }
5867 case other => fail(s " This is not a directory statement coverage! [ $other] " )
5968 }
6069 }
@@ -111,4 +120,14 @@ class XmlScoverageReportConstructingParserSpec extends FlatSpec with Matchers {
111120 private def checkRate (expected : Double , real : Double ) {
112121 BigDecimal (real).setScale(2 , BigDecimal .RoundingMode .HALF_UP ).should(equal(BigDecimal (expected)))
113122 }
123+
124+ private def checkNode (node : NodeStatementCoverage , name : String , count : Int , covered : Int , rate : Double ): Iterable [NodeStatementCoverage ] = {
125+ node.name shouldEqual name
126+ node.statementCount shouldEqual count
127+ node.coveredStatementsCount shouldEqual covered
128+
129+ checkRate(rate, node.rate)
130+
131+ node.children
132+ }
114133}
0 commit comments