-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
85 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/java/fr/inria/diversify/dspot/amp/TestMethodCallAdderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package fr.inria.diversify.dspot.amp; | ||
|
||
import fr.inria.diversify.Utils; | ||
import org.junit.Test; | ||
import spoon.Launcher; | ||
import spoon.reflect.code.CtStatement; | ||
import spoon.reflect.declaration.CtClass; | ||
import spoon.reflect.declaration.CtMethod; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Created by Benjamin DANGLOT | ||
* benjamin.danglot@inria.fr | ||
* on 12/7/16 | ||
*/ | ||
public class TestMethodCallAdderTest { | ||
|
||
@Test | ||
public void testMethodCallAdd() throws Exception { | ||
|
||
/* | ||
Test that we duplicate method call in a test for each used method in the test. | ||
3 method are called in the original test, we produce 3 test methods. | ||
*/ | ||
|
||
Launcher launcher = Utils.buildSpoon(); | ||
CtClass<Object> testClass = launcher.getFactory().Class().get("mutation.ClassUnderTestTest"); | ||
|
||
TestMethodCallAdder methodCallAdder = new TestMethodCallAdder(); | ||
AmplifierHelper.reset(); | ||
|
||
final CtMethod<?> originalMethod = testClass.getMethods().stream().filter(m -> "testAddCall".equals(m.getSimpleName())).findFirst().get(); | ||
List<CtMethod> amplifiedMethods = methodCallAdder.apply(originalMethod); | ||
|
||
assertEquals(3, amplifiedMethods.size()); | ||
|
||
for (int i = 0 ; i < amplifiedMethods.size() ; i++) { | ||
CtMethod amplifiedMethod = amplifiedMethods.get(i); | ||
assertEquals(originalMethod.getBody().getStatements().size() + 1, amplifiedMethod.getBody().getStatements().size()); | ||
CtStatement expectedStatement = originalMethod.getBody().getStatements().get(i+1);//+1 to skip the construction statement. | ||
assertEquals(expectedStatement, amplifiedMethod.getBody().getStatements().get(i+1)); | ||
assertEquals(expectedStatement, amplifiedMethod.getBody().getStatements().get(i+2)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters