/** {@inheritDoc} */ @Override public String getTestString(int id, TestCase test, Map<Integer, Throwable> exceptions) { return test.toCode(exceptions); }
/** {@inheritDoc} */ @Override public String getTestString(int id, TestCase test, Map<Integer, Throwable> exceptions) { return test.toCode(exceptions); }
/** {@inheritDoc} */ @Override public String toString() { return test.toCode(); }
private void preFitnessDebugInfo(ExecutionResult result, boolean respectPrintFlag) { if (PRINT_DEBUG || !respectPrintFlag) { System.out.println("=============================================================="); System.out.println("current goal: " + toString()); System.out.println("current test:"); System.out.println(result.test.toCode()); } }
@Override public String toString() { String testSuiteString = ""; for (TestChromosome test : tests) { testSuiteString += ((RegressionTestChromosome) test).getTheTest() .getTestCase().toCode(); testSuiteString += "\n"; } return testSuiteString; }
public void inferTypes(TestCase test) { this.test = test; logger.debug("Inferring generic types"); // calculateExactTypes(); for (int i = test.size() - 1; i >= 0; i--) { Statement statement = test.getStatement(i); if (statement instanceof ConstructorStatement) { determineExactType((ConstructorStatement) statement); } } logger.debug("Resulting test: "+test.toCode()); }
/** * Helper method to add sequences * * @param sequence */ private void addSequence(ObjectSequence sequence) { if (!pool.containsKey(sequence.getGeneratedClass())) pool.put(sequence.getGeneratedClass(), new HashSet<TestCase>()); pool.get(sequence.getGeneratedClass()).add(sequence.getSequence()); logger.info("Added new sequence for " + sequence.getGeneratedClass()); logger.info(sequence.getSequence().toCode()); }
/** {@inheritDoc} */ @Override public void addAssertions(TestCase test) { ExecutionResult result = runTest(test); for (OutputTrace<?> trace : result.getTraces()) { trace.getAllAssertions(test); trace.clear(); } logger.debug("Test after adding assertions: " + test.toCode()); } }
@Test public void testBeanDateConverterUtils2() { Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.DateConverterTest2.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); }
@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); }
@Test public void testBeanDateConverterUtils1() { Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.DateConverterTest1.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); }
@Test public void testBeanDateConverterUtils5() { Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.DateConverterTest5.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); }
@Test public void testBeanDateConverterUtils11() { Properties.SELECTED_JUNIT = com.examples.with.different.packagename.testcarver.DateConverterTest11.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); }
@Test public void testExcludeMethod() throws Exception{ TestChromosome tc = new TestChromosome(); TestFactory factory = TestFactory.getInstance(); //'reset' is a method that shouldn't be used in a test factory.addMethod(tc.getTestCase(), new GenericMethod(EvoServletState.class.getDeclaredMethod("reset"), EvoServletState.class), 0, 0); Assert.assertEquals(tc.getTestCase().toCode(), 1, tc.size()); Assert.assertFalse(ConstraintVerifier.verifyTest(tc)); }
@Ignore @Test public void test3() { TestSuiteChromosome suite = generateSuite(ExampleInheritedClass.class); Assert.assertTrue(suite.size() > 0); for (TestCase test : suite.getTests()) { Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions()); } }
@Ignore @Test public void test3() { TestSuiteChromosome suite = generateSuite(ExampleInheritedClass.class); Assert.assertTrue(suite.size() > 0); for (TestCase test : suite.getTests()) { Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions()); } }
@Ignore @Test public void test2() { TestSuiteChromosome suite = generateSuite(ExampleFieldClass.class); Assert.assertTrue(suite.size() > 0); for (TestCase test : suite.getTests()) { Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions()); } }
@Ignore @Test public void test2() { TestSuiteChromosome suite = generateSuite(ExampleFieldClass.class); Assert.assertTrue(suite.size() > 0); for (TestCase test : suite.getTests()) { Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions()); } }
@Ignore @Test public void test4() { TestSuiteChromosome suite = generateSuite(ExampleStaticVoidSetterClass.class); Assert.assertTrue(suite.size() > 0); for (TestCase test : suite.getTests()) { Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions()); } }
@Ignore @Test public void test4() { TestSuiteChromosome suite = generateSuite(ExampleStaticVoidSetterClass.class); Assert.assertTrue(suite.size() > 0); for (TestCase test : suite.getTests()) { if (test.size() > 1) Assert.assertTrue("Test has no assertions: " + test.toCode(), test.hasAssertions()); } }