use of fr.inria.diversify.dspot.amplifier.TestDataMutator in project dspot by STAMP-project.
the class ExecutedMutantSelectorTest method test.
@Ignore
@Test
public void test() throws Exception {
// pre computing the number of executed mutants...
Main.verbose = true;
AutomaticBuilderFactory.getAutomaticBuilder(Utils.getInputConfiguration()).runPit(Utils.getInputProgram().getProgramDir());
final List<PitResult> pitResults = PitResultParser.parseAndDelete(Utils.getInputProgram().getProgramDir() + "target/pit-reports/");
final ExecutedMutantSelector testSelector = new ExecutedMutantSelector();
DSpot dspot = new DSpot(Utils.getInputConfiguration(), 1, Collections.singletonList(new TestDataMutator()), testSelector);
final CtType amplifyTest = dspot.amplifyTest(Utils.findClass("example.TestSuiteExample"), Collections.singletonList(Utils.findMethod("example.TestSuiteExample", "test8")));
// pretty print it
DSpotUtils.printCtTypeToGivenDirectory(amplifyTest, new File(DSpotCompiler.pathToTmpTestSources));
// then compile
final String classpath = AutomaticBuilderFactory.getAutomaticBuilder(Utils.getInputConfiguration()).buildClasspath(Utils.getInputProgram().getProgramDir()) + AmplificationHelper.PATH_SEPARATOR + Utils.getInputProgram().getProgramDir() + "/" + Utils.getInputProgram().getClassesDir() + AmplificationHelper.PATH_SEPARATOR + "target/dspot/dependencies/" + AmplificationHelper.PATH_SEPARATOR + Utils.getInputProgram().getProgramDir() + "/" + Utils.getInputProgram().getTestClassesDir();
DSpotCompiler.compile(DSpotCompiler.pathToTmpTestSources, classpath, new File(Utils.getInputProgram().getProgramDir() + "/" + Utils.getInputProgram().getTestClassesDir()));
AutomaticBuilderFactory.getAutomaticBuilder(Utils.getInputConfiguration()).runPit(Utils.getInputProgram().getProgramDir());
final List<PitResult> amplifiedPitResults = PitResultParser.parseAndDelete(Utils.getInputProgram().getProgramDir() + "target/pit-reports/");
assertTrue(pitResults.stream().filter(pitResult -> pitResult.getStateOfMutant() == PitResult.State.KILLED || pitResult.getStateOfMutant() == PitResult.State.SURVIVED).count() < amplifiedPitResults.stream().filter(pitResult -> pitResult.getStateOfMutant() == PitResult.State.KILLED || pitResult.getStateOfMutant() == PitResult.State.SURVIVED).count());
Main.verbose = false;
}
use of fr.inria.diversify.dspot.amplifier.TestDataMutator in project dspot by STAMP-project.
the class JacocoCoverageSelectorTest method testDSpotWithJacocoCoverageSelector.
@Test
public void testDSpotWithJacocoCoverageSelector() throws Exception {
try {
FileUtils.deleteDirectory(new File("target/trash"));
} catch (Exception ignored) {
// ignored
}
AmplificationHelper.setSeedRandom(23L);
InputConfiguration configuration = new InputConfiguration("src/test/resources/test-projects/test-projects.properties");
DSpot dspot = new DSpot(configuration, 2, Arrays.asList(new TestDataMutator(), new StatementAdd()), new JacocoCoverageSelector());
dspot.amplifyTest("example.TestSuiteExample", Collections.singletonList("test2"));
try (BufferedReader buffer = new BufferedReader(new FileReader(configuration.getOutputDirectory() + "example.TestSuiteExample_jacoco_instr_coverage_report.txt"))) {
assertEquals(expectedReport, buffer.lines().collect(Collectors.joining(nl)));
}
}
use of fr.inria.diversify.dspot.amplifier.TestDataMutator in project dspot by STAMP-project.
the class ProjectJSONTest method test.
@Test
public void test() throws Exception {
final File file = new File("target/trash/sample.json");
if (file.exists()) {
file.delete();
}
DSpot dspot = new DSpot(new InputConfiguration("src/test/resources/sample/sample.properties"), 1, Collections.singletonList(new TestDataMutator()), new JacocoCoverageSelector());
dspot.amplifyTest("fr.inria.amp.TestJavaPoet");
try (BufferedReader buffer = new BufferedReader(new FileReader(file))) {
final String jsonAsString = buffer.lines().collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR));
assertTrue(jsonAsString.startsWith(expectedFirstProjectJSON[0]));
assertTrue(jsonAsString.endsWith(expectedFirstProjectJSON[1]));
}
dspot.amplifyTest("fr.inria.mutation.ClassUnderTestTest");
try (BufferedReader buffer = new BufferedReader(new FileReader(file))) {
final String jsonAsString = buffer.lines().collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR));
assertTrue(jsonAsString.startsWith(expectedFirstProjectJSON[0]));
assertTrue(jsonAsString.contains(expectedFirstProjectJSON[2]));
assertTrue(jsonAsString.endsWith(expectedFirstProjectJSON[3]));
}
dspot.amplifyTest("fr.inria.amp.TestJavaPoet");
try (BufferedReader buffer = new BufferedReader(new FileReader(file))) {
final String jsonAsString = buffer.lines().collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR));
assertTrue(jsonAsString.startsWith(expectedFirstProjectJSON[0]));
assertTrue(jsonAsString.endsWith(expectedFirstProjectJSON[1]));
}
}
use of fr.inria.diversify.dspot.amplifier.TestDataMutator in project dspot by STAMP-project.
the class Main method runExample.
static void runExample() {
try {
InputConfiguration configuration = new InputConfiguration("src/test/resources/test-projects/test-projects.properties");
DSpot dSpot = new DSpot(configuration, 1, Collections.singletonList(new TestDataMutator()), new JacocoCoverageSelector());
dSpot.amplifyTest("example.TestSuiteExample");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of fr.inria.diversify.dspot.amplifier.TestDataMutator in project dspot by STAMP-project.
the class DSpotTest method testInheritanceMethod.
@Test
public void testInheritanceMethod() throws Exception {
/*
Test that DSpot can be run on an abstract test, using its implementation.
*/
final InputConfiguration configuration = new InputConfiguration("src/test/resources/sample/sample.properties");
DSpot dspot = new DSpot(configuration, 3, Collections.singletonList(new TestDataMutator()), new JacocoCoverageSelector());
CtType<?> ctType = dspot.amplifyTest("fr.inria.inheritance.Inherited").get(0);
assertEquals(1, ctType.getMethods().size());
}
Aggregations