Skip to content

Commit

Permalink
explanatory comments and removind unnecessary code pointed out by Danyao
Browse files Browse the repository at this point in the history
  • Loading branch information
lacinoire committed Feb 7, 2022
1 parent 9702be9 commit 74b94d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public DevFriendlyAmplification(DSpot dSpot, DSpotState dSpotState, Amplificatio
public List<CtMethod<?>> devFriendlyAmplification(CtType<?> testClassToBeAmplified,
List<CtMethod<?>> testMethodsToBeAmplified) {

// first we setup the selector so it can compute the complete coverage of the whole existing test suite
final List<CtMethod<?>> selectedToBeAmplified = dSpot
.setupSelector(testClassToBeAmplified,
dSpotState.getTestFinder().findTestMethods(testClassToBeAmplified,Collections.emptyList()));
.setupSelector(testClassToBeAmplified, testMethodsToBeAmplified);

// selectedToBeAmplified with all test class methods -> keep only ones matching testMethodsToBeAmplified
final List<CtMethod<?>> methodsToAmplify =
Expand Down Expand Up @@ -106,11 +106,8 @@ public List<CtMethod<?>> inputAmplification(CtType<?> testClassToBeAmplified,
classWithTestMethods = testTuple.testClassToBeAmplified;

// Amplify input
List<CtMethod<?>> selectedForInputAmplification = setup
.fullSelectorSetup(classWithTestMethods, testTuple.testMethodsToBeAmplified);

List<CtMethod<?>> inputAmplifiedTests = dSpotState.getInputAmplDistributor()
.inputAmplify(selectedForInputAmplification, 0);
.inputAmplify(testTuple.testMethodsToBeAmplified, 0);

// Add new assertions
amplifiedTests = dSpotState.getAssertionGenerator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public MethodReconstructor(double delta,
*/
public List<CtMethod<?>> addAssertions(CtType<?> testClass, List<CtMethod<?>> testCases) {
Map<String, Observation> observations;

if (devFriendlyAmplification) {
// We add the test cases before the input amplification, so that we also observe the values there.
// Later we only pick values for an assertion when the value is different than in the parent
testCases.addAll(AmplificationHelper.getFirstParentsIfExist(testCases));
}

Expand Down Expand Up @@ -147,6 +150,9 @@ private CtMethod<?> buildTestWithAssert(CtMethod test, Map<String, Observation>
/**
* Adds new assertions one by one to generate several new test cases.
*
* Jumps over assertions that would have been identical in the parent test case (before the amplification
* modifications). This helps us generate assertions that are related to the modifications.
*
* @param test Original test method
* @param observations Observation points of the test suite
* @return A list of tests, each with a different new assertion of an observation point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,7 @@ public List<CtMethod<?>> firstSelectorSetup(CtType<?> testClassToBeAmplified,
GLOBAL_REPORT.addError(new Error(ERROR_EXEC_TEST_BEFORE_AMPLIFICATION, e));
throw new Exception();
}
final List<CtMethod<?>> selectedToBeAmplified;
try {
selectedToBeAmplified = testSelector.selectToAmplify(testClassToBeAmplified, passingTests);
} catch (Exception | java.lang.Error e) {
GLOBAL_REPORT.addError(new Error(ERROR_PRE_SELECTION, e));
throw new Exception();
}
return selectedToBeAmplified;
return fullSelectorSetup(testClassToBeAmplified, passingTests);
}

public List<CtMethod<?>> fullSelectorSetup(CtType<?> testClassToBeAmplified,
Expand Down

0 comments on commit 74b94d9

Please sign in to comment.