All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scoverage.report.CoberturaXmlWriter.scala Maven / Gradle / Ivy

The newest version!
package scoverage.report

import java.io.File

import scoverage.DoubleFormat.twoFractionDigits
import scoverage._

import scala.xml.{Node, PrettyPrinter}

/** @author Stephen Samuel */
class CoberturaXmlWriter(sourceDirectories: Seq[File], outputDir: File) extends BaseReportWriter(sourceDirectories, outputDir) {

  def this (baseDir: File, outputDir: File) {
    this(Seq(baseDir), outputDir)
  }

  def write(coverage: Coverage): Unit = {
    val file = new File(outputDir, "cobertura.xml")
    IOUtils.writeToFile(file, "\n\n" +
        new PrettyPrinter(120, 4).format(xml(coverage)))
  }

  def method(method: MeasuredMethod): Node = {
    
      
        {method.statements.map(stmt =>
          
      )}
      
    
  }

  def klass(klass: MeasuredClass): Node = {
    
      
        {klass.methods.map(method)}
      
      
        {klass.statements.map(stmt =>
          
      )}
      
    
  }

  def pack(pack: MeasuredPackage): Node = {
    
      
        {pack.classes.map(klass)}
      
    
  }

  def source(src: File): Node = {
    {src.getCanonicalPath.replace(File.separator, "/")}
  }

  def xml(coverage: Coverage): Node = {
    
      
        --source
        {sourceDirectories.filter(_.isDirectory).map(source)}
      
      
        {coverage.packages.map(pack)}
      
    
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy