Search in sources :

Example 1 with InitializeDSpot

use of eu.stamp_project.dspot.common.configuration.InitializeDSpot in project dspot by STAMP-project.

the class ProjectJSONTest method setUp.

@Before
public void setUp() {
    super.setUp();
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot(getPathToProjectRoot());
    this.configuration.setOutputDirectory(outputDirectory);
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    this.initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, this.builder);
    DSpotUtils.init(CommentEnum.None, outputDirectory, this.configuration.getFullClassPathWithExtraDependencies(), this.getPathToProjectRoot());
    this.compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
    DSpotCache.init(10000);
    Launcher launcher = new Launcher();
    launcher.getEnvironment().setNoClasspath(true);
    launcher.addInputResource(this.getPathToProjectRoot());
    launcher.buildModel();
    this.factory = launcher.getFactory();
    TestFramework.init(this.factory);
    testCompiler = new TestCompiler(0, false, this.getPathToProjectRoot(), this.configuration.getClasspathClassesProject(), 10000, "", false);
    AssertionGeneratorUtils.init(false);
    DSpotPOMCreator.createNewPom(configuration);
    RandomHelper.setSeedRandom(72L);
    ValueCreator.count = 0;
    this.testSelector = new JacocoCoverageSelector(builder, configuration);
    try {
        FileUtils.forceDelete(new File(outputDirectory));
    } catch (Exception ignored) {
    }
}
Also used : TestCompiler(eu.stamp_project.dspot.common.compilation.TestCompiler) JacocoCoverageSelector(eu.stamp_project.dspot.selector.JacocoCoverageSelector) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) Before(org.junit.Before)

Example 2 with InitializeDSpot

use of eu.stamp_project.dspot.common.configuration.InitializeDSpot in project dspot by STAMP-project.

the class DSpotUtilsTest method setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    super.setUp();
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot(getPathToProjectRoot());
    this.configuration.setOutputDirectory(outputDirectory.getAbsolutePath());
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    this.initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, this.builder);
    DSpotUtils.init(CommentEnum.None, outputDirectory.getAbsolutePath(), this.configuration.getFullClassPathWithExtraDependencies(), this.getPathToProjectRoot());
    this.compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
}
Also used : UserInput(eu.stamp_project.dspot.common.configuration.UserInput) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) Before(org.junit.Before)

Example 3 with InitializeDSpot

use of eu.stamp_project.dspot.common.configuration.InitializeDSpot in project dspot by STAMP-project.

the class Main method run.

public static List<CtMethod<?>> run(CtType<?> amplifiedTestClass, UserInput configuration) {
    InitializeDSpot initializeDSpot = new InitializeDSpot();
    final AutomaticBuilder automaticBuilder = configuration.getBuilderEnum().getAutomaticBuilder(configuration);
    final String dependencies = initializeDSpot.completeDependencies(configuration, automaticBuilder);
    final DSpotCompiler compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
    configuration.setFactory(compiler.getLauncher().getFactory());
    initializeDSpot.initHelpers(configuration);
    final List<CtMethod<?>> testMethods = TestFramework.getAllTest(amplifiedTestClass);
    Main.report.nbTestMethods = testMethods.size();
    final List<CtMethod<?>> minimizedAmplifiedTestMethods;
    // 1 minimize amplified test methods
    if (configuration.isApplyAllPrettifiers() || configuration.isApplyGeneralMinimizer() || configuration.isApplyPitMinimizer()) {
        minimizedAmplifiedTestMethods = applyMinimization(testMethods, amplifiedTestClass, configuration);
    } else {
        minimizedAmplifiedTestMethods = testMethods;
    }
    // 2 rename test methods
    if (configuration.isApplyAllPrettifiers() || configuration.isRenameTestMethods()) {
        applyCode2Vec(minimizedAmplifiedTestMethods, configuration);
    }
    // 3 rename local variables TODO train one better model
    final List<CtMethod<?>> prettifiedTestMethods;
    if (configuration.isApplyAllPrettifiers() || configuration.isRenameLocalVariables()) {
        prettifiedTestMethods = applyContext2Name(minimizedAmplifiedTestMethods);
    } else {
        prettifiedTestMethods = minimizedAmplifiedTestMethods;
    }
    return prettifiedTestMethods;
}
Also used : AutomaticBuilder(eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder) DSpotCompiler(eu.stamp_project.dspot.common.compilation.DSpotCompiler) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) CtMethod(spoon.reflect.declaration.CtMethod)

Example 4 with InitializeDSpot

use of eu.stamp_project.dspot.common.configuration.InitializeDSpot in project dspot by STAMP-project.

the class AbstractSelectorRemoveOverlapTest method setUp.

@Before
public void setUp() {
    DSpotState.verbose = true;
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot(getPathToAbsoluteProjectRoot());
    this.configuration.setOutputDirectory(outputDirectory);
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    this.initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, this.builder);
    DSpotUtils.init(CommentEnum.None, outputDirectory, this.configuration.getFullClassPathWithExtraDependencies(), this.getPathToAbsoluteProjectRoot());
    this.compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
    DSpotCache.init(10000);
    Launcher launcher = new Launcher();
    launcher.getEnvironment().setNoClasspath(true);
    launcher.addInputResource(this.getPathToAbsoluteProjectRoot());
    launcher.buildModel();
    this.factory = launcher.getFactory();
    TestFramework.init(this.factory);
    this.testCompiler = new TestCompiler(0, false, this.getPathToAbsoluteProjectRoot(), this.configuration.getClasspathClassesProject(), 10000, "", false);
    AssertionGeneratorUtils.init(false);
    DSpotPOMCreator.createNewPom(configuration);
    RandomHelper.setSeedRandom(72L);
    ValueCreator.count = 0;
    this.testSelectorUnderTest = this.getTestSelector();
}
Also used : TestCompiler(eu.stamp_project.dspot.common.compilation.TestCompiler) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) Before(org.junit.Before)

Example 5 with InitializeDSpot

use of eu.stamp_project.dspot.common.configuration.InitializeDSpot in project dspot by STAMP-project.

the class AbstractSelectorTest method setUp.

@Before
public void setUp() throws Exception {
    DSpotState.verbose = true;
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot(getPathToAbsoluteProjectRoot());
    this.configuration.setOutputDirectory(outputDirectory);
    this.configuration.setGregorMode(true);
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    this.initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, this.builder);
    DSpotUtils.init(CommentEnum.None, outputDirectory, this.configuration.getFullClassPathWithExtraDependencies(), this.getPathToAbsoluteProjectRoot());
    this.compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
    DSpotCache.init(10000);
    Launcher launcher = new Launcher();
    launcher.getEnvironment().setNoClasspath(true);
    launcher.addInputResource(this.getPathToAbsoluteProjectRoot());
    launcher.buildModel();
    this.factory = launcher.getFactory();
    TestFramework.init(this.factory);
    this.testRunner = new TestRunner(this.getPathToAbsoluteProjectRoot(), "", false);
    this.testCompiler = new TestCompiler(0, false, this.getPathToAbsoluteProjectRoot(), this.configuration.getClasspathClassesProject(), 10000, "", false);
    AssertionGeneratorUtils.init(false);
    DSpotPOMCreator.createNewPom(configuration);
    RandomHelper.setSeedRandom(72L);
    ValueCreator.count = 0;
    this.testSelectorUnderTest = this.getTestSelector();
}
Also used : TestCompiler(eu.stamp_project.dspot.common.compilation.TestCompiler) TestRunner(eu.stamp_project.dspot.common.execution.TestRunner) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) Before(org.junit.Before)

Aggregations

InitializeDSpot (eu.stamp_project.dspot.common.configuration.InitializeDSpot)10 UserInput (eu.stamp_project.dspot.common.configuration.UserInput)8 AutomaticBuilder (eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder)5 Before (org.junit.Before)5 Launcher (spoon.Launcher)5 TestCompiler (eu.stamp_project.dspot.common.compilation.TestCompiler)3 DSpotCompiler (eu.stamp_project.dspot.common.compilation.DSpotCompiler)2 TestRunner (eu.stamp_project.dspot.common.execution.TestRunner)2 File (java.io.File)2 Test (org.junit.Test)2 CtMethod (spoon.reflect.declaration.CtMethod)2 JacocoCoverageSelector (eu.stamp_project.dspot.selector.JacocoCoverageSelector)1 ArrayList (java.util.ArrayList)1 BeforeClass (org.junit.BeforeClass)1 Factory (spoon.reflect.factory.Factory)1