use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testGenericParameter.
@Test
public void testGenericParameter() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.GenericTest.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.ObjectWrapper.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertTrue(factory.hasCarvedTestCases());
TestChromosome carved = factory.getChromosome();
Assert.assertNotNull(carved);
Assert.assertEquals("", 5, carved.test.size());
for (int i = 0; i < carved.test.size(); i++) {
Statement stmt = carved.test.getStatement(i);
boolean valid = stmt.isValid();
Assert.assertTrue("Invalid stmt at position " + i, valid);
}
String code = carved.toString();
String setLong = "HashSet<Long>";
Assert.assertTrue("generated code does not contain " + setLong + "\n" + code, code.contains(setLong));
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testObjectWrapperSequence.
@Test
public void testObjectWrapperSequence() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.ObjectWrapperSequenceTest.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.ObjectWrapper.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertTrue(factory.hasCarvedTestCases());
TestChromosome carved = factory.getChromosome();
Assert.assertNotNull(carved);
Assert.assertEquals("", 6, carved.test.size());
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testPrimitives.
@Test
public void testPrimitives() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.PrimitivesTest.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.ObjectWrapper.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertTrue(factory.hasCarvedTestCases());
TestChromosome carved = factory.getChromosome();
Assert.assertNotNull(carved);
String code = carved.toString();
Assert.assertEquals(code, 19, carved.test.size());
String concatenated = "0123.04.0567";
Assert.assertTrue("generated code does not contain " + concatenated + "\n" + code, code.contains(concatenated));
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testInnerCalls.
@Test
public void testInnerCalls() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.InnerCallsTest.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.InnerCalls.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertTrue(factory.hasCarvedTestCases());
TestChromosome carved = factory.getChromosome();
Assert.assertNotNull(carved);
String code = carved.toString();
Assert.assertNotNull(code);
Assert.assertEquals(code, 4, carved.test.size());
for (int i = 0; i < carved.test.size(); i++) {
Statement stmt = carved.test.getStatement(i);
boolean valid = stmt.isValid();
Assert.assertTrue("Invalid stmt at position " + i, valid);
}
System.out.println(code);
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testSimpleTest.
@Test
public void testSimpleTest() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.SimpleTest.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.Simple.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
TestChromosome carved = factory.getChromosome();
Assert.assertNotNull(carved);
Assert.assertEquals("Should be: constructor, method, 2 variables, method, 1 variable, method", 7, carved.test.size());
}
Aggregations