Search in sources :

Example 1 with CoberturaData

use of jscover.report.coberturaxml.CoberturaData in project JSCover by tntim96.

the class Main method saveCoberturaXml.

public void saveCoberturaXml() {
    String json = ioUtils.loadFromFileSystem(new File(config.getJsonDirectory(), "jscoverage.json"));
    String xml = coberturaXmlGenerator.generateXml(new CoberturaData(jsonDataMerger.jsonToMap(json).values()), ioUtils.getCanonicalPath(config.getSourceDirectory()), config.getVersion());
    File dest = new File(config.getJsonDirectory(), "cobertura-coverage.xml");
    ioUtils.copy(xml, dest);
}
Also used : File(java.io.File) CoberturaData(jscover.report.coberturaxml.CoberturaData)

Example 2 with CoberturaData

use of jscover.report.coberturaxml.CoberturaData in project JSCover by tntim96.

the class MainTest method shouldRunCoberturaXmlReport.

@Test
public void shouldRunCoberturaXmlReport() throws IOException {
    given(config.getReportFormat()).willReturn(ReportFormat.COBERTURAXML);
    given(config.getVersion()).willReturn("version");
    File jsonDirectory = new File("jsonDir");
    File srcDir = new File("src");
    given(config.getJsonDirectory()).willReturn(jsonDirectory);
    given(config.getSourceDirectory()).willReturn(srcDir);
    String json = "json";
    given(ioUtils.loadFromFileSystem(new File(jsonDirectory, "jscoverage.json"))).willReturn(json);
    doReturn(srcDir.getCanonicalPath()).when(ioUtils).getCanonicalPath(srcDir);
    SortedMap<String, FileData> list = new TreeMap<>();
    given(jsonDataMerger.jsonToMap(json)).willReturn(list);
    given(coberturaXmlGenerator.generateXml(ArgumentMatchers.any(), anyString(), anyString())).willReturn("<xml/>");
    main.runMain(new String[] {});
    TypeSafeMatcher<CoberturaData> coberturaDataMatcher = new TypeSafeMatcher<CoberturaData>() {

        @Override
        protected boolean matchesSafely(CoberturaData coverable) {
            return true;
        }

        public void describeTo(Description description) {
        }
    };
    File xmlFile = new File(jsonDirectory, "cobertura-coverage.xml");
    verify(coberturaXmlGenerator).generateXml(argThat(coberturaDataMatcher), argThat(is(srcDir.getCanonicalPath())), argThat(is("version")));
    verify(ioUtils).copy("<xml/>", xmlFile);
    verifyNoInteractions(exitHelper);
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) TreeMap(java.util.TreeMap) File(java.io.File) CoberturaData(jscover.report.coberturaxml.CoberturaData) Test(org.junit.Test)

Aggregations

File (java.io.File)2 CoberturaData (jscover.report.coberturaxml.CoberturaData)2 TreeMap (java.util.TreeMap)1 Description (org.hamcrest.Description)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 Test (org.junit.Test)1