1 21 22 package net.sourceforge.cobertura.reporting.xml; 23 24 import java.io.File ; 25 26 import junit.framework.TestCase; 27 import net.sourceforge.cobertura.coveragedata.ClassData; 28 import net.sourceforge.cobertura.coveragedata.ProjectData; 29 import net.sourceforge.cobertura.reporting.ComplexityCalculator; 30 import net.sourceforge.cobertura.reporting.JUnitXMLHelper; 31 import net.sourceforge.cobertura.util.FileFinder; 32 33 public class XMLReportTest extends TestCase 34 { 35 36 private final static String BASEDIR = (System.getProperty("basedir") != null) ? System 37 .getProperty("basedir") : "."; 38 private final static String PATH_TO_TEST_OUTPUT = BASEDIR + "/build/test/XMLReportTest"; 39 private File tmpDir; 40 41 public void setUp() 42 { 43 tmpDir = new File (PATH_TO_TEST_OUTPUT); 44 tmpDir.mkdirs(); 45 } 46 47 public void tearDown() 48 { 49 tmpDir = new File (PATH_TO_TEST_OUTPUT); 50 File files[] = tmpDir.listFiles(); 51 for (int i = 0; i < files.length; i++) 52 files[i].delete(); 53 tmpDir.delete(); 54 } 55 56 public void testXMLReportWithNonSourceLines() throws Exception 57 { 58 ProjectData projectData = new ProjectData(); 59 60 ClassData cd = projectData.getOrCreateClassData(XMLReport.class.getName()); 62 cd.touch(7777); 63 64 File reportDir = File.createTempFile("XMLReportTest", ""); 65 reportDir.delete(); 66 reportDir.mkdir(); 67 68 FileFinder fileFinder = new FileFinder(); 69 ComplexityCalculator complexity = new ComplexityCalculator(fileFinder); 70 71 new XMLReport(projectData, reportDir, fileFinder, complexity); 72 73 File coverageFile = new File (reportDir, "coverage.xml"); 74 JUnitXMLHelper.readXmlFile(coverageFile, true); 75 76 coverageFile.delete(); 77 reportDir.delete(); 78 } 79 80 } 81 | Popular Tags |