use of eu.stamp_project.dspot.common.configuration.UserInput 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.UserInput 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.UserInput in project dspot by STAMP-project.
the class MavenAutomaticBuilder method buildMavenHome.
private String buildMavenHome(UserInput configuration) {
String mavenHome = null;
if (configuration != null) {
if (configuration.getMavenHome() != null && !configuration.getMavenHome().isEmpty()) {
mavenHome = configuration.getMavenHome();
} else {
mavenHome = getMavenHome(envVariable -> System.getenv().get(envVariable) != null, envVariable -> System.getenv().get(envVariable), "MAVEN_HOME", "M2_HOME");
if (mavenHome == null) {
mavenHome = getMavenHome(path -> new File(path).exists(), Function.identity(), "/usr/share/maven/", "/usr/local/maven-3.3.9/", "/usr/share/maven3/", "/usr/share/apache-maven-3.8.1/");
if (mavenHome == null) {
throw new RuntimeException("Maven home not found, please set properly MAVEN_HOME or M2_HOME.");
}
}
// update the value inside the input configuration
configuration.setMavenHome(mavenHome);
}
}
return mavenHome;
}
use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.
the class AbstractTest method setUp.
@Before
public void setUp() throws Exception {
RandomHelper.setSeedRandom(72L);
ValueCreator.count = 0;
this.configuration = new UserInput();
this.configuration.setAbsolutePathToProjectRoot(this.getAbsolutePathToProjectRoot());
this.configuration.setVerbose(true);
this.configuration.setBuilderEnum(AutomaticBuilderEnum.Maven);
this.configuration.setGregorMode(true);
DSpotState.verbose = true;
Utils.init(this.configuration);
}
use of eu.stamp_project.dspot.common.configuration.UserInput in project dspot by STAMP-project.
the class TestMethodCallAdder method setUp.
@Before
@Override
public void setUp() {
super.setUp();
UserInput configuration = new UserInput();
configuration.setAbsolutePathToProjectRoot(new File("src/test/resources/sample/").getAbsolutePath());
DSpotUtils.init(CommentEnum.Amplifier, "target/dspot/", configuration.getFullClassPathWithExtraDependencies(), "src/test/resources/sample/");
}
Aggregations