Search in sources :

Example 21 with UserInput

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

the class GradleAutomaticBuilderWithDescartesTest method setUp.

@Before
public void setUp() throws Exception {
    DSpotState.verbose = true;
    cleanTestEnv();
    LOGGER.debug("Test Set-up - Reading input parameters...");
    LOGGER.debug("Test Set-up - instantiating Automatic Builder (SUT)...");
    final UserInput configuration = new UserInput();
    configuration.setAbsolutePathToProjectRoot(this.pathToProjectRoot);
    configuration.setGregorMode(true);
    configuration.setFilter("example.*");
    launcher = new Launcher();
    launcher.addInputResource(pathToProjectRoot + "src/");
    launcher.getEnvironment().setNoClasspath(true);
    launcher.buildModel();
    sut = AutomaticBuilderEnum.Gradle.getAutomaticBuilder(configuration);
    sut.compile();
    LOGGER.debug("Test Set-up complete.");
    parser = new PitXMLResultParser();
}
Also used : PitXMLResultParser(eu.stamp_project.dspot.selector.pitmutantscoreselector.PitXMLResultParser) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) Launcher(spoon.Launcher) Before(org.junit.Before)

Example 22 with UserInput

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

the class DSpotPOMCreatorTest method testOnPOMWithProfiles.

@Test
public void testOnPOMWithProfiles() throws Exception {
    /*
            Test the copy and the injection of the profile on a pom with an existing profiles tag
         */
    // TODO system properties are not used in DSpotPOMCreator
    UserInput configuration = new UserInput();
    configuration.setFilter("fr.inria.sample.*");
    configuration.setAbsolutePathToProjectRoot("src/test/resources/sample/");
    configuration.setJVMArgs("-Xmx2048m,-Xms1024m");
    configuration.setSystemProperties("-Dis.admin.user=admin,-Dis.admin.passwd=$2pRSid#");
    configuration.setExcludedClasses("fr.inria.filter.failing.*");
    DSpotPOMCreator.createNewPom(configuration);
    try (BufferedReader reader = new BufferedReader(new FileReader(configuration.getAbsolutePathToProjectRoot() + DSpotPOMCreator.getPOMName()))) {
        final String content = reader.lines().collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR));
        assertTrue(content + AmplificationHelper.LINE_SEPARATOR + "should be ends with " + AmplificationHelper.LINE_SEPARATOR + PROFILE_ENDS_WITH, content.replaceAll(" ", "").endsWith(PROFILE_ENDS_WITH.replaceAll(" ", "")));
    }
}
Also used : BufferedReader(java.io.BufferedReader) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 23 with UserInput

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

the class DSpotPOMCreatorTest method test.

@Test
public void test() throws Exception {
    /*
            Test the copy and injection of the profile to run different foals in the origial pom.xml
         */
    UserInput configuration = new UserInput();
    configuration.setFilter("example.*");
    configuration.setAbsolutePathToProjectRoot("src/test/resources/test-projects/");
    configuration.setJVMArgs("-Xmx2048m,-Xms1024m");
    DSpotPOMCreator.createNewPom(configuration);
    try (BufferedReader reader = new BufferedReader(new FileReader(configuration.getAbsolutePathToProjectRoot() + DSpotPOMCreator.getPOMName()))) {
        final String content = reader.lines().collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR));
        assertTrue(content + AmplificationHelper.LINE_SEPARATOR + "must contain " + AmplificationHelper.LINE_SEPARATOR + MUST_CONTAIN, content.contains(MUST_CONTAIN));
        assertTrue(content + AmplificationHelper.LINE_SEPARATOR + "should be ends with " + AmplificationHelper.LINE_SEPARATOR + ENDS_WITH, content.endsWith(ENDS_WITH));
    }
}
Also used : BufferedReader(java.io.BufferedReader) UserInput(eu.stamp_project.dspot.common.configuration.UserInput) FileReader(java.io.FileReader) Test(org.junit.Test)

Example 24 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput 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 25 with UserInput

use of eu.stamp_project.dspot.common.configuration.UserInput 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

UserInput (eu.stamp_project.dspot.common.configuration.UserInput)26 Before (org.junit.Before)11 Test (org.junit.Test)10 InitializeDSpot (eu.stamp_project.dspot.common.configuration.InitializeDSpot)8 Launcher (spoon.Launcher)8 File (java.io.File)7 AutomaticBuilder (eu.stamp_project.dspot.common.automaticbuilder.AutomaticBuilder)5 TestCompiler (eu.stamp_project.dspot.common.compilation.TestCompiler)4 PitXMLResultParser (eu.stamp_project.dspot.selector.pitmutantscoreselector.PitXMLResultParser)3 BufferedReader (java.io.BufferedReader)3 FileReader (java.io.FileReader)3 TestRunner (eu.stamp_project.dspot.common.execution.TestRunner)2 ArrayList (java.util.ArrayList)2 CtMethod (spoon.reflect.declaration.CtMethod)2 DSpot (eu.stamp_project.dspot.DSpot)1 DSpotState (eu.stamp_project.dspot.common.configuration.DSpotState)1 InputErrorException (eu.stamp_project.dspot.common.configuration.check.InputErrorException)1 DSpotUtils (eu.stamp_project.dspot.common.miscellaneous.DSpotUtils)1 JacocoCoverageSelector (eu.stamp_project.dspot.selector.JacocoCoverageSelector)1 IOException (java.io.IOException)1