Search in sources :

Example 1 with GeneralMinimizer

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;
}
Also used : PitMutantMinimizer(eu.stamp_project.prettifier.minimization.PitMutantMinimizer) GeneralMinimizer(eu.stamp_project.prettifier.minimization.GeneralMinimizer) AutomaticBuilder(eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder) TypeFilter(spoon.reflect.visitor.filter.TypeFilter) CtMethod(spoon.reflect.declaration.CtMethod)

Aggregations

AutomaticBuilder (eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder)1 GeneralMinimizer (eu.stamp_project.prettifier.minimization.GeneralMinimizer)1 PitMutantMinimizer (eu.stamp_project.prettifier.minimization.PitMutantMinimizer)1 CtMethod (spoon.reflect.declaration.CtMethod)1 TypeFilter (spoon.reflect.visitor.filter.TypeFilter)1