use of org.evosuite.statistics.SearchStatistics in project evosuite by EvoSuite.
the class CoverageAnalysisOfClassSystemTest method testOneClassOneCriterion.
@Test
public void testOneClassOneCriterion() {
EvoSuite evosuite = new EvoSuite();
String targetClass = Calculator.class.getCanonicalName();
String testClass = CalculatorTest.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH };
String[] command = new String[] { "-class", targetClass, "-Djunit=" + testClass, "-measureCoverage" };
SearchStatistics statistics = (SearchStatistics) evosuite.parseCommandLine(command);
Assert.assertNotNull(statistics);
Map<String, OutputVariable<?>> outputVariables = statistics.getOutputVariables();
assertEquals(0.80, (Double) outputVariables.get("BranchCoverage").getValue(), 0.0);
assertEquals(0.80, (Double) outputVariables.get("Coverage").getValue(), 0.0);
assertEquals(4, (Integer) outputVariables.get("Tests_Executed").getValue(), 0);
assertEquals(4, (Integer) outputVariables.get("Covered_Goals").getValue(), 0);
assertEquals(5, (Integer) outputVariables.get("Total_Goals").getValue(), 0);
assertEquals("10111", outputVariables.get("BranchCoverageBitString").getValue());
}
use of org.evosuite.statistics.SearchStatistics in project evosuite by EvoSuite.
the class CoverageAnalysisOfProjectSystemTest method testMoreThanOneClassOneCriterion.
@Test
public void testMoreThanOneClassOneCriterion() throws IOException {
createFakeProject();
EvoSuite evosuite = new EvoSuite();
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.LINE };
Properties.STATISTICS_BACKEND = StatisticsBackend.CSV;
String[] command = new String[] { "-target", this.classes_directory.getAbsolutePath(), "-Djunit=" + this.tests_directory.getAbsolutePath(), "-projectCP", this.classes_directory.getAbsolutePath() + File.pathSeparator + this.tests_directory.getAbsolutePath(), "-measureCoverage" };
SearchStatistics statistics = (SearchStatistics) evosuite.parseCommandLine(command);
Assert.assertNotNull(statistics);
String statistics_file = System.getProperty("user.dir") + File.separator + Properties.REPORT_DIR + File.separator + "statistics.csv";
CSVReader reader = new CSVReader(new FileReader(statistics_file));
List<String[]> rows = reader.readAll();
// header + 7 classes
assertEquals(8, rows.size());
reader.close();
// assert TargetClasses
List<String> classes = CsvJUnitData.getValues(rows, "TARGET_CLASS");
assertTrue(classes.contains(Calculator.class.getCanonicalName()));
assertTrue(classes.contains(MethodWithSeveralInputArguments.class.getCanonicalName()));
assertTrue(classes.contains(WordUtils.class.getCanonicalName()));
assertTrue(classes.contains(FinalClass.class.getCanonicalName()));
assertTrue(classes.contains(StringUtils.class.getCanonicalName()));
assertTrue(classes.contains(ClassNumberUtils.class.getCanonicalName()));
assertTrue(classes.contains(ClassWithPrivateInterfaces.class.getCanonicalName()));
// assert Coverage
List<String> coverages = CsvJUnitData.getValues(rows, "Coverage");
assertTrue(coverages.size() == 7);
Collections.sort(coverages);
assertEquals(0.80, Double.valueOf(coverages.get(0)), 0.01);
assertEquals(0.80, Double.valueOf(coverages.get(1)), 0.00);
assertEquals(0.90, Double.valueOf(coverages.get(2)), 0.00);
assertEquals(0.93, Double.valueOf(coverages.get(3)), 0.01);
assertEquals(0.95, Double.valueOf(coverages.get(4)), 0.00);
assertEquals(1.00, Double.valueOf(coverages.get(5)), 0.00);
assertEquals(1.00, Double.valueOf(coverages.get(6)), 0.00);
}
use of org.evosuite.statistics.SearchStatistics in project evosuite by EvoSuite.
the class CoverageAnalysisSystemTest method testBranchCoverage.
@Test
public void testBranchCoverage() {
SearchStatistics statistics = this.aux(new Properties.Criterion[] { Properties.Criterion.BRANCH });
Map<String, OutputVariable<?>> variables = statistics.getOutputVariables();
assertEquals(9, (Integer) variables.get("Total_Goals").getValue(), 0.0);
assertEquals(9, (Integer) variables.get("Covered_Goals").getValue(), 0.0);
}
use of org.evosuite.statistics.SearchStatistics in project evosuite by EvoSuite.
the class CoverageAnalysisSystemTest method testLineCoverage.
@Test
public void testLineCoverage() {
SearchStatistics statistics = this.aux(new Properties.Criterion[] { Properties.Criterion.LINE });
Map<String, OutputVariable<?>> variables = statistics.getOutputVariables();
assertEquals(11, (Integer) variables.get("Total_Goals").getValue(), 0.0);
assertEquals(11, (Integer) variables.get("Covered_Goals").getValue(), 0.0);
}
use of org.evosuite.statistics.SearchStatistics in project evosuite by EvoSuite.
the class CoverageAnalysisSystemTest method testCBranchCoverage.
@Test
public void testCBranchCoverage() {
SearchStatistics statistics = this.aux(new Properties.Criterion[] { Properties.Criterion.CBRANCH });
Map<String, OutputVariable<?>> variables = statistics.getOutputVariables();
assertEquals(9, (Integer) variables.get("Total_Goals").getValue(), 0.0);
assertEquals(9, (Integer) variables.get("Covered_Goals").getValue(), 0.0);
}
Aggregations