Search in sources :

Example 1 with JacocoCoverageSelector

use of fr.inria.diversify.dspot.selector.JacocoCoverageSelector in project dspot by STAMP-project.

the class DSpotSelectionTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    Utils.reset();
    final InputConfiguration inputConfiguration = new InputConfiguration("src/test/resources/test-projects/test-projects.properties");
    Main.createOutputDirectories(inputConfiguration, true);
    dspotUnderTest = new MockedDSpot(inputConfiguration, 1, new JacocoCoverageSelector());
}
Also used : JacocoCoverageSelector(fr.inria.diversify.dspot.selector.JacocoCoverageSelector) InputConfiguration(fr.inria.diversify.utils.sosiefier.InputConfiguration) BeforeClass(org.junit.BeforeClass)

Example 2 with JacocoCoverageSelector

use of fr.inria.diversify.dspot.selector.JacocoCoverageSelector in project dspot by STAMP-project.

the class DSpotTest method testExcludedClassesInPropertyFile.

@Test
public void testExcludedClassesInPropertyFile() throws Exception {
    /*
            Usage of properties:
                - excludedClasses: list of full qualified name of test classes to be excluded (separated by comma ',')
                - excludedTestCases: list of name of test cases (methods) to be excluded (separated by comma ',')
         */
    final MockDSpot dSpot = new MockDSpot(Utils.getInputConfiguration(), 1, Collections.singletonList(new TestMethodCallAdder()), new JacocoCoverageSelector());
    // the test class fr.inria.filter.passing.PassingTest has 2 method, but only one is amplified
    assertEquals(2, Utils.findClass("fr.inria.filter.passing.PassingTest").getMethods().size());
    // the test class fr.inria.filter.failing.FailingTest match the regex, but it is excluded in the properties
    final List<CtType> ctTypes = dSpot.amplifyTest("fr.inria.filter.*");
    assertEquals(1, ctTypes.size());
    // uses the mock to retrieve the number of method to be amplified
    assertEquals(1, dSpot.numberOfMethod);
}
Also used : CtType(spoon.reflect.declaration.CtType) TestMethodCallAdder(fr.inria.diversify.dspot.amplifier.TestMethodCallAdder) JacocoCoverageSelector(fr.inria.diversify.dspot.selector.JacocoCoverageSelector) Test(org.junit.Test) AbstractTest(fr.inria.AbstractTest)

Example 3 with JacocoCoverageSelector

use of fr.inria.diversify.dspot.selector.JacocoCoverageSelector 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]));
    }
}
Also used : JacocoCoverageSelector(fr.inria.diversify.dspot.selector.JacocoCoverageSelector) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) InputConfiguration(fr.inria.diversify.utils.sosiefier.InputConfiguration) TestDataMutator(fr.inria.diversify.dspot.amplifier.TestDataMutator) Test(org.junit.Test)

Example 4 with JacocoCoverageSelector

use of fr.inria.diversify.dspot.selector.JacocoCoverageSelector 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);
    }
}
Also used : DSpot(fr.inria.diversify.dspot.DSpot) JacocoCoverageSelector(fr.inria.diversify.dspot.selector.JacocoCoverageSelector) InputConfiguration(fr.inria.diversify.utils.sosiefier.InputConfiguration) IOException(java.io.IOException) TestDataMutator(fr.inria.diversify.dspot.amplifier.TestDataMutator)

Example 5 with JacocoCoverageSelector

use of fr.inria.diversify.dspot.selector.JacocoCoverageSelector in project dspot by STAMP-project.

the class DSpotMultiplePomTest method testCopyMultipleModuleProject.

@Test
public void testCopyMultipleModuleProject() throws Exception {
    /*
            Contract: DSpot is able to amplify a multi-module project
         */
    Main.verbose = true;
    EntryPoint.verbose = true;
    final InputConfiguration configuration = new InputConfiguration("src/test/resources/multiple-pom/deep-pom-modules.properties");
    final DSpot dspot = new DSpot(configuration, new JacocoCoverageSelector());
    final List<CtType> ctTypes = dspot.amplifyAllTests();
    assertFalse(ctTypes.isEmpty());
    EntryPoint.verbose = false;
    Main.verbose = false;
}
Also used : CtType(spoon.reflect.declaration.CtType) JacocoCoverageSelector(fr.inria.diversify.dspot.selector.JacocoCoverageSelector) InputConfiguration(fr.inria.diversify.utils.sosiefier.InputConfiguration) Test(org.junit.Test)

Aggregations

JacocoCoverageSelector (fr.inria.diversify.dspot.selector.JacocoCoverageSelector)6 InputConfiguration (fr.inria.diversify.utils.sosiefier.InputConfiguration)5 Test (org.junit.Test)4 TestDataMutator (fr.inria.diversify.dspot.amplifier.TestDataMutator)3 AbstractTest (fr.inria.AbstractTest)2 CtType (spoon.reflect.declaration.CtType)2 DSpot (fr.inria.diversify.dspot.DSpot)1 TestMethodCallAdder (fr.inria.diversify.dspot.amplifier.TestMethodCallAdder)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 BeforeClass (org.junit.BeforeClass)1