public RegressionTestChromosome() { // TODO Auto-generated constructor stub theClassLoader = TestGenerationContext.getInstance().getRegressionClassLoaderForSUT(); }
.getClassAsStream(classFullPath); InputStream regressionClassIS = ResourceList .getInstance(TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()) .getClassAsStream(classFullPath);
private void initCache() { cache = new Cache(); String cp = ClassPathHandler.getInstance().getTargetProjectClasspath(); // If running in regression mode and current ClassLoader is the regression ClassLoader if(Properties.isRegression() && classLoader==TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()) cp = org.evosuite.Properties.REGRESSIONCP; for(String entry : cp.split(File.pathSeparator)){ addEntry(entry); } }
try { is = isRegression ? ResourceList.getInstance(TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()).getClassAsStream(fullyQualifiedTargetClass)
public static boolean sameCFG() { Collection<Branch> branchesOriginal = BranchPool .getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).getAllBranches(); Collection<Branch> branchesRegression = BranchPool.getInstance(TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()) .getAllBranches(); if (branchesOriginal.size() != branchesRegression.size()) { logger.error("Different number of branches between two versions: {} vs {}", branchesOriginal.size(), branchesRegression.size()); return false; } Iterator<Branch> branchesOriginalIterator = branchesOriginal.iterator(); Iterator<Branch> branchesRegressionIterator = branchesRegression.iterator(); boolean sameBranches = true; while (branchesOriginalIterator.hasNext()) { Branch bOrig = branchesOriginalIterator.next(); Branch bReg = branchesRegressionIterator.next(); int bOrigOpcode = bOrig.getInstruction().getASMNode().getOpcode(); int bRegOpcode = bReg.getInstruction().getASMNode().getOpcode(); // Are branches from the same family of branches? if (!Objects.equals(RegressionClassDiff.getBranchFamily(bOrigOpcode), RegressionClassDiff .getBranchFamily(bRegOpcode))) { logger.error("Different family found between branches: {} vs {}", bOrigOpcode, bRegOpcode); sameBranches = false; break; } } return sameBranches; }
@Override public Chromosome clone() { RegressionTestChromosome copy = new RegressionTestChromosome(); copy.theClassLoader = TestGenerationContext.getInstance() .getRegressionClassLoaderForSUT(); // I don't think this should be a member of this class to be honest! copy.theTest = (TestChromosome) theTest.clone(); copy.theSameTestForTheOtherClassLoader = (TestChromosome) theSameTestForTheOtherClassLoader .clone(); copy.setFitnessValues(getFitnessValues()); copy.diversityMap.putAll(diversityMap); copy.exCommentsAdded = exCommentsAdded; return copy; }
public RegressionSuiteFitness() { super(); logger.warn("### initialising Regression-GA... ###"); initBranchMap(); try { TestGenerationContext.getInstance().getRegressionClassLoaderForSUT() .loadClass(Properties.TARGET_CLASS); } catch (ClassNotFoundException e) { e.printStackTrace(); } // init branch coverage fitness bcFitness = new BranchCoverageSuiteFitness(); bcFitnessRegression = new BranchCoverageSuiteFitness( TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()); // set branch coverage max values maxBranchFitnessValueO = bcFitness.getMaxValue(); maxBranchFitnessValueR = bcFitnessRegression.getMaxValue(); observer = new RegressionExecutionObserver(); ExecutionTracer.enableTraceCalls(); }
/** * */ protected void updateClassloader() { if (theTest.isChanged()) { theSameTestForTheOtherClassLoader = (TestChromosome) theTest.clone(); ((DefaultTestCase) theSameTestForTheOtherClassLoader.getTestCase()) .changeClassLoader(TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()); } }
TestGenerationContext.getInstance().getRegressionClassLoaderForSUT());
return TestGenerationResultBuilder.buildErrorResult("Could not load target regression class"); if (!ResourceList.getInstance(TestGenerationContext.getInstance().getRegressionClassLoaderForSUT()) .hasClass(Properties.TARGET_CLASS)) { Properties.IGNORE_MISSING_STATISTICS = false;