private static void initInheritanceTree(List<String> classPath) { logger.debug("Calculate inheritance hierarchy"); inheritanceTree = InheritanceTreeGenerator.createFromClassPath(classPath); TestClusterGenerator clusterGenerator = new TestClusterGenerator(inheritanceTree); TestGenerationContext.getInstance().setTestClusterGenerator(clusterGenerator); InheritanceTreeGenerator.gatherStatistics(inheritanceTree); }
/** * As RESET_STATIC_FINAL_FIELDS=true removes the <code>final</code> modifier * of static fields in the target class, the purpose of this test case is to * check that the TestClusterGenerator indeed does not include these fields. * * * @throws ClassNotFoundException * @throws RuntimeException */ @Test public void test() throws ClassNotFoundException, RuntimeException { Properties.TARGET_CLASS = FinalPrimitiveField.class.getCanonicalName(); Properties.RESET_STATIC_FINAL_FIELDS = true; ClassPathHandler.getInstance().changeTargetCPtoTheSameAsEvoSuite(); String cp = ClassPathHandler.getInstance().getTargetProjectClasspath(); DependencyAnalysis.analyzeClass(Properties.TARGET_CLASS, Arrays.asList(cp.split(File.pathSeparator))); InheritanceTree tree = DependencyAnalysis.getInheritanceTree(); TestClusterGenerator gen = new TestClusterGenerator(tree); assertNotNull(gen); TestCluster cluster = TestCluster.getInstance(); List<GenericAccessibleObject<?>> testCalls = cluster.getTestCalls(); assertEquals("Unexpected number of TestCalls", 2, testCalls.size()); }
/** * As RESET_STATIC_FINAL_FIELDS=true removes the <code>final</code> modifier * of static fields in the target class, the purpose of this test case is to * check that the TestClusterGenerator indeed does not include these fields. * * * @throws ClassNotFoundException * @throws RuntimeException */ @Test public void test() throws ClassNotFoundException, RuntimeException { Properties.TARGET_CLASS = FinalReferenceField.class.getCanonicalName(); Properties.RESET_STATIC_FINAL_FIELDS = true; ClassPathHandler.getInstance().changeTargetCPtoTheSameAsEvoSuite(); String cp = ClassPathHandler.getInstance().getTargetProjectClasspath(); DependencyAnalysis.analyzeClass(Properties.TARGET_CLASS, Arrays.asList(cp.split(File.pathSeparator))); InheritanceTree tree = DependencyAnalysis.getInheritanceTree(); TestClusterGenerator gen = new TestClusterGenerator(tree); assertNotNull(gen); TestCluster cluster = TestCluster.getInstance(); List<GenericAccessibleObject<?>> testCalls = cluster.getTestCalls(); assertEquals("Unexpected number of TestCalls", 2, testCalls.size()); }
testClusterGenerator = new TestClusterGenerator( DependencyAnalysis.getInheritanceTree());