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);
}
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());
}
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;
}
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);
}
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());
}
Aggregations