use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class StandardChemicalReactionSystemTest method testIntermolecularIneffectiveCollision.
@Test
public void testIntermolecularIneffectiveCollision() {
GeneticAlgorithm<?> ga = test(1.0, -1, -1);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
Assert.assertEquals(6, best.getNumOfCoveredGoals());
Assert.assertEquals(6.0 / 9.0, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class StandardChemicalReactionSystemTest method testSynthesis.
@Test
public void testSynthesis() {
GeneticAlgorithm<?> ga = test(1.0, -1, 1_000_000);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
Assert.assertEquals(7, best.getNumOfCoveredGoals());
Assert.assertEquals(7.0 / 9.0, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class LambdaInStaticConstructorSystemTest method testNoCrashInCLINIT.
@Test
public void testNoCrashInCLINIT() throws Throwable {
String targetClass = LambdaInStaticConstructor.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.TIMEOUT = 50000000;
Properties.RESET_STATIC_FINAL_FIELDS = true;
EvoSuite evosuite = new EvoSuite();
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println(best.toString());
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class AbstractErrorBranchTest method checkErrorBranches.
protected void checkErrorBranches(Class<?> targetClass, int realBranches, int instrumentedBranches, int coveredRealBranches, int coveredInstrumentedBranches) {
TestSuiteChromosome best = runEvoSuite(targetClass);
assertBranchStats(realBranches, instrumentedBranches, coveredRealBranches, coveredInstrumentedBranches);
Assert.assertEquals(realBranches, TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size());
Assert.assertEquals(instrumentedBranches, TestGenerationStrategy.getFitnessFactories().get(1).getCoverageGoals().size());
double meanCoverage = 0.0;
if (instrumentedBranches > 0) {
meanCoverage += (double) coveredInstrumentedBranches / instrumentedBranches;
} else {
meanCoverage += 1.0;
}
if (realBranches > 0) {
meanCoverage += (double) coveredRealBranches / realBranches;
} else {
meanCoverage += 1.0;
}
meanCoverage /= 2.0;
Assert.assertEquals("Non-optimal coverage: ", meanCoverage, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class AbstractErrorBranchTest method runEvoSuite.
private TestSuiteChromosome runEvoSuite(Class<?> targetClass) {
EvoSuite evosuite = new EvoSuite();
String targetClassName = targetClass.getCanonicalName();
Properties.TARGET_CLASS = targetClassName;
Properties.ASSERTIONS = false;
Properties.JUNIT_TESTS = false;
Properties.JUNIT_CHECK = false;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.BRANCH, Properties.Criterion.TRYCATCH };
String[] command = new String[] { "-generateSuite", "-class", targetClassName };
StringBuilder s = new StringBuilder();
s.append(RuntimeVariable.Coverage);
s.append(",");
s.append(RuntimeVariable.BranchCoverage);
s.append(",");
s.append(RuntimeVariable.Covered_Goals);
s.append(",");
s.append(RuntimeVariable.Total_Goals);
s.append(",");
s.append(RuntimeVariable.Covered_Branches);
s.append(",");
s.append(RuntimeVariable.Covered_Branchless_Methods);
s.append(",");
s.append(RuntimeVariable.Covered_Branches_Real);
s.append(",");
s.append(RuntimeVariable.Covered_Branches_Instrumented);
s.append(",");
Properties.OUTPUT_VARIABLES = s.toString();
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println(best.toString());
return best;
}
Aggregations