use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class ObjectPoolSystemTest method testDifficultClassWithWrongPoolFails.
@Ignore
@Test
public void testDifficultClassWithWrongPoolFails() {
EvoSuite evosuite = new EvoSuite();
String targetClass = DifficultClassWithoutCarving.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.P_OBJECT_POOL = 0.8;
Properties.CARVE_OBJECT_POOL = true;
Properties.SELECTED_JUNIT = ArrayConverterTestCase.class.getCanonicalName();
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
Assert.assertTrue("Did not expect optimal coverage: ", best.getCoverage() < 1d);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class TypeSeedingSystemTest method testTypeExampleOff.
@Test
public void testTypeExampleOff() {
EvoSuite evosuite = new EvoSuite();
String targetClass = TypeExample.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEED_TYPES = false;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
int goals = TestSuiteGenerator.getFitnessFactories().get(0).getCoverageGoals().size();
Assert.assertEquals("Wrong number of goals: ", 4, goals);
Assert.assertTrue("Did not expect optimal coverage: ", best.getCoverage() < 1d);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class TypeSeedingSystemTest method testObjectToStringCase.
@Test
public void testObjectToStringCase() {
EvoSuite evosuite = new EvoSuite();
String targetClass = ObjectCastExample.class.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.SEED_TYPES = true;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class BIMutatedMethodSeedingTestSuiteChromosomeFactorySystemTest method testBIMutatedMethod.
@Test
public void testBIMutatedMethod() {
// probability is SEED_PROBABILITY/test cases, so 10 guarentees a seed
Properties.SEED_PROBABILITY = 10;
// Test requires configured test cluster otherwise
Properties.SEED_MUTATIONS = 0;
BIMutatedMethodSeedingTestSuiteChromosomeFactory factory = new BIMutatedMethodSeedingTestSuiteChromosomeFactory(defaultFactory, bestIndividual);
TestSuiteChromosome chromosome = factory.getChromosome();
boolean containsMutatedSeededMethod = false;
for (TestCase t : chromosome.getTests()) {
for (TestCase t2 : bestIndividual.getTests()) {
if (!t.equals(t2) && !t.equals(TestSampleFactory.CHROMOSOME)) {
// test case not from original BI or from sample factory,
// so must be seeded mutated BI
containsMutatedSeededMethod = true;
}
}
}
assertTrue(containsMutatedSeededMethod);
}
use of org.evosuite.testsuite.TestSuiteChromosome in project evosuite by EvoSuite.
the class InjectionSystemTest method doTest.
private void doTest(Class<?> target) {
EvoSuite evosuite = new EvoSuite();
String targetClass = target.getCanonicalName();
Properties.TARGET_CLASS = targetClass;
Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.LINE };
Properties.JEE = true;
Properties.P_REFLECTION_ON_PRIVATE = 0.0;
// Takes extra time to set up the DBManager which is useless
Properties.ASSERTIONS = false;
String[] command = new String[] { "-generateSuite", "-class", targetClass };
Object result = evosuite.parseCommandLine(command);
GeneticAlgorithm<?> ga = getGAFromResult(result);
TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
System.out.println("EvolvedTestSuite:\n" + best);
Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
}
Aggregations