use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testGenericClassSet.
@Test
public void testGenericClassSet() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.GenericObjectWrapperSetTest.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.GenericObjectWrapper.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("", 13, 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 = "GenericObjectWrapper<HashSet<Long>>";
Assert.assertTrue("generated code does not contain " + setLong + "\n" + code, code.contains(setLong));
code = carved.toString();
setLong = "(Object)";
Assert.assertFalse("generated code contains object cast " + setLong + "\n" + code, code.contains(setLong));
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testBeanIntegerConverterUtils.
@Test
public void testBeanIntegerConverterUtils() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.IntegerConverterTestCase.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.IntegerConverter.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertEquals(18, factory.getNumCarvedTestCases());
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testReadPublicStaticField.
@Test
public void testReadPublicStaticField() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.ClassWithPublicStaticFieldReadingTestCase.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.ClassWithPublicStaticField.class.getCanonicalName();
Properties.SEED_MUTATIONS = 0;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertEquals(1, factory.getNumCarvedTestCases());
TestChromosome test = factory.getChromosome();
String code = test.getTestCase().toCode();
System.out.println(code);
Assert.assertFalse(code.contains("XStream"));
Assert.assertTrue(code.contains("ClassWithPublicStaticField.x"));
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testBeanDateConverterUtils3.
@Test
public void testBeanDateConverterUtils3() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.DateConverterTest3.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.DateConverter.class.getCanonicalName();
Properties.SEED_MUTATIONS = 1;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertEquals(1, factory.getNumCarvedTestCases());
String code = factory.getChromosome().getTestCase().toCode();
System.out.println(code);
}
use of org.evosuite.testcase.factories.JUnitTestCarvedChromosomeFactory in project evosuite by EvoSuite.
the class JUnitTestCarvedChromosomeFactorySystemTest method testReadPublicStaticFieldInOtherClass.
@Test
public void testReadPublicStaticFieldInOtherClass() {
Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.ClassDependingOnStaticFieldInOtherClassTestCase.class.getCanonicalName();
Properties.TARGET_CLASS = com.examples.with.different.packagename.testcarver.ClassDependingOnStaticFieldInOtherClass.class.getCanonicalName();
Properties.SEED_MUTATIONS = 0;
Properties.SEED_CLONE = 1;
JUnitTestCarvedChromosomeFactory factory = new JUnitTestCarvedChromosomeFactory(null);
Assert.assertEquals(1, factory.getNumCarvedTestCases());
TestChromosome test = factory.getChromosome();
String code = test.getTestCase().toCode();
System.out.println(code);
Assert.assertFalse(code.contains("XStream"));
Assert.assertTrue(code.contains("StaticFieldInOtherClass.x"));
}
Aggregations