use of eu.stamp_project.prettifier.minimization.GeneralMinimizer in project dspot by STAMP-project.
the class Main method applyMinimization.
public static List<CtMethod<?>> applyMinimization(List<CtMethod<?>> amplifiedTestMethodsToBeMinimized, CtType<?> amplifiedTestClass, UserInput configuration) {
Main.report.medianNbStatementBefore = Main.getMedian(amplifiedTestMethodsToBeMinimized.stream().map(ctMethod -> ctMethod.getElements(new TypeFilter<>(CtStatement.class))).map(List::size).collect(Collectors.toList()));
// 1 apply general minimization
if (configuration.isApplyAllPrettifiers() || configuration.isApplyGeneralMinimizer()) {
amplifiedTestMethodsToBeMinimized = Main.applyGivenMinimizer(new GeneralMinimizer(), amplifiedTestMethodsToBeMinimized);
// update the test class with minimized test methods
final ArrayList<CtMethod<?>> allMethods = new ArrayList<>(amplifiedTestClass.getMethods());
allMethods.stream().filter(TestFramework.get()::isTest).forEach(amplifiedTestClass::removeMethod);
amplifiedTestMethodsToBeMinimized.forEach(amplifiedTestClass::addMethod);
}
// 2 apply pit minimization
if (configuration.isApplyAllPrettifiers() || configuration.isApplyPitMinimizer()) {
final AutomaticBuilder automaticBuilder = configuration.getBuilderEnum().getAutomaticBuilder(configuration);
amplifiedTestMethodsToBeMinimized = Main.applyGivenMinimizer(new PitMutantMinimizer(amplifiedTestClass, automaticBuilder, configuration.getAbsolutePathToProjectRoot(), configuration.getClasspathClassesProject(), configuration.getAbsolutePathToTestClasses()), amplifiedTestMethodsToBeMinimized);
}
Main.report.medianNbStatementAfter = Main.getMedian(amplifiedTestMethodsToBeMinimized.stream().map(ctMethod -> ctMethod.getElements(new TypeFilter<>(CtStatement.class))).map(List::size).collect(Collectors.toList()));
return amplifiedTestMethodsToBeMinimized;
}
Aggregations