use of fr.inria.diversify.dspot.selector.json.coverage.TestCaseJSON in project dspot by STAMP-project.
the class JacocoCoverageSelector method jsonReport.
private void jsonReport(CoverageResults coverageResults) {
TestClassJSON testClassJSON;
Gson gson = new GsonBuilder().setPrettyPrinting().create();
final File file = new File(this.configuration.getOutputDirectory() + "/" + this.currentClassTestToBeAmplified.getQualifiedName() + "_jacoco_instr_coverage.json");
if (file.exists()) {
try {
testClassJSON = gson.fromJson(new FileReader(file), TestClassJSON.class);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
} else {
testClassJSON = new TestClassJSON(this.currentClassTestToBeAmplified.getQualifiedName(), this.currentClassTestToBeAmplified.getMethods().size(), this.initialCoverage.instructionsCovered, this.initialCoverage.instructionsTotal, coverageResults.instructionsCovered, coverageResults.instructionsTotal);
}
this.selectedAmplifiedTest.forEach(ctMethod -> new TestCaseJSON(ctMethod.getSimpleName(), Counter.getInputOfSinceOrigin(ctMethod), Counter.getAssertionOfSinceOrigin(ctMethod), this.selectedToBeAmplifiedCoverageResultsMap.get(ctMethod.getSimpleName()).instructionsCovered, this.selectedToBeAmplifiedCoverageResultsMap.get(ctMethod.getSimpleName()).instructionsTotal));
try (FileWriter writer = new FileWriter(file, false)) {
writer.write(gson.toJson(testClassJSON));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations