use of org.evosuite.coverage.MethodNameMatcher in project evosuite by EvoSuite.
the class BranchCoverageFactory method computeCoverageGoals.
/**
* return coverage goals of the target class or of all the contextual branches, depending on the limitToCUT paramether
* @param limitToCUT
* @return
*/
private List<BranchCoverageTestFitness> computeCoverageGoals(boolean limitToCUT) {
long start = System.currentTimeMillis();
List<BranchCoverageTestFitness> goals = new ArrayList<BranchCoverageTestFitness>();
// logger.info("Getting branches");
for (String className : BranchPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).knownClasses()) {
// when limitToCUT== true, if not the class under test of a inner/anonymous class, continue
if (limitToCUT && !isCUT(className))
continue;
// when limitToCUT==false, consider all classes, but excludes libraries ones according the INSTRUMENT_LIBRARIES property
if (!limitToCUT && (!Properties.INSTRUMENT_LIBRARIES && !DependencyAnalysis.isTargetProject(className)))
continue;
final MethodNameMatcher matcher = new MethodNameMatcher();
// Branchless methods
for (String method : BranchPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).getBranchlessMethods(className)) {
if (matcher.fullyQualifiedMethodMatches(method)) {
goals.add(createRootBranchTestFitness(className, method));
}
}
// Branches
for (String methodName : BranchPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).knownMethods(className)) {
if (!matcher.methodMatches(methodName)) {
logger.info("Method " + methodName + " does not match criteria. ");
continue;
}
for (Branch b : BranchPool.getInstance(TestGenerationContext.getInstance().getClassLoaderForSUT()).retrieveBranchesInMethod(className, methodName)) {
if (!b.isInstrumented()) {
goals.add(createBranchCoverageTestFitness(b, true));
goals.add(createBranchCoverageTestFitness(b, false));
}
}
}
}
goalComputationTime = System.currentTimeMillis() - start;
return goals;
}
Aggregations