Search in sources :

Example 6 with InitializeDSpot

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

the class OneTestClassPitScoreMutantSelectorTest method setUp.

@Before
public void setUp() {
    DSpotState.verbose = true;
    this.configuration = new UserInput();
    this.configuration.setAbsolutePathToProjectRoot("src/test/resources/test-projects/");
    this.builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    this.initializeDSpot = new InitializeDSpot();
    DSpotCompiler.createDSpotCompiler(configuration, initializeDSpot.completeDependencies(configuration, this.builder));
    Launcher launcher = new Launcher();
    launcher.getEnvironment().setNoClasspath(true);
    launcher.addInputResource("src/test/resources/test-projects/");
    launcher.buildModel();
    Factory factory = launcher.getFactory();
    this.configuration.setFactory(factory);
    this.configuration.setTestClasses(Collections.singletonList(FULL_QUALIFIED_NAME_TEST_CLASS));
    this.configuration.setTargetOneTestClass(true);
    this.testRunner = new TestRunner(this.configuration.getAbsolutePathToProjectRoot(), "", false);
}
Also used : TestRunner(eu.stamp_project.dspot.common.execution.TestRunner) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) Factory(spoon.reflect.factory.Factory) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) Before(org.junit.Before)

Example 7 with InitializeDSpot

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

the class TestCompilerTest method test.

@Test
public void test() {
    final UserInput configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot(getPathToProjectRoot());
    final AutomaticBuilder builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    InitializeDSpot initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, builder);
    configuration.setDependencies(dependencies);
    DSpotCompiler compiler = DSpotCompiler.createDSpotCompiler(configuration, dependencies);
    CtClass<?> testClass = findClass("fr.inria.filter.failing.FailingTest");
    final ArrayList<CtMethod<?>> methods = new ArrayList<>();
    methods.add(findMethod(testClass, "testAssertionError"));
    methods.add(findMethod(testClass, "testFailingWithException"));
    DSpotUtils.init(CommentEnum.None, "target/dspot/", configuration.getFullClassPathWithExtraDependencies(), getPathToProjectRoot());
    TestCompiler testCompiler = new TestCompiler(0, false, getPathToProjectRoot(), configuration.getClasspathClassesProject(), 10000, "", false);
    assertTrue(testCompiler.compileRunAndDiscardUncompilableAndFailingTestMethods(testClass, methods, compiler).isEmpty());
    testClass = findClass("fr.inria.filter.passing.PassingTest");
    methods.clear();
    methods.add(findMethod(testClass, "testAssertion"));
    methods.add(findMethod(testClass, "testNPEExpected"));
    methods.add(findMethod(testClass, "failingTestCase"));
    assertEquals(2, testCompiler.compileRunAndDiscardUncompilableAndFailingTestMethods(testClass, methods, compiler).size());
}
Also used : AutomaticBuilder(eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder) ArrayList(java.util.ArrayList) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Example 8 with InitializeDSpot

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

the class Utils method init.

public static void init(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);
    Utils.configuration = configuration;
}
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)

Example 9 with InitializeDSpot

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

the class AssertionGeneratorTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot(new File("src/test/resources/sample/").getAbsolutePath());
    AutomaticBuilder builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    initializeDSpot = new InitializeDSpot();
    dependencies = initializeDSpot.completeDependencies(configuration, builder);
}
Also used : AutomaticBuilder(eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 10 with InitializeDSpot

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

the class AssertionRemoverTest method testOnDifferentKindOfAssertions.

@Test
public void testOnDifferentKindOfAssertions() throws Exception {
    /*
            Test that the AssertionRemover remove all kind of assertions
		 */
    UserInput configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot(new File(getPathToProjectRoot()).getAbsolutePath());
    // new TestCompiler(0,
    // false,
    // configuration.getAbsolutePathToProjectRoot(),
    // configuration.getClasspathClassesProject(),
    // 10000,
    // "",
    // false
    // 
    // );
    AutomaticBuilder builder = AutomaticBuilderEnum.Maven.getAutomaticBuilder(configuration);
    InitializeDSpot initializeDSpot = new InitializeDSpot();
    String dependencies = initializeDSpot.completeDependencies(configuration, builder);
    launcher = new Launcher();
    launcher.addInputResource(getPathToProjectRoot());
    launcher.getEnvironment().setOutputType(OutputType.CLASSES);
    launcher.getModelBuilder().setSourceClasspath(dependencies.split(AmplificationHelper.PATH_SEPARATOR));
    launcher.buildModel();
    final CtClass<?> testClass = findClass("fr.inria.helper.TestWithMultipleAsserts");
    final AssertionRemover assertionRemover = new AssertionRemover();
    final CtMethod<?> testMethod = testClass.getMethodsByName("test").get(0);
    final CtMethod<?> removedAssertion = assertionRemover.removeAssertions(testMethod, true);
    assertEquals(4, removedAssertion.getBody().getStatements().size());
}
Also used : AutomaticBuilder(eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) InitializeDSpot(eu.stamp_project.dspot.common.configuration.InitializeDSpot) File(java.io.File) Test(org.junit.Test)

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