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);
}
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);
}
Aggregations