@Override public void addAssertions(TestCase test) { if (!(test instanceof StructuredTestCase)) throw new IllegalArgumentException("Expecting StructuredTestCase"); StructuredTestCase structuredTest = (StructuredTestCase) test; Set<String> targetMethods = structuredTest.getTargetMethods(); List<Mutation> mutants = MutationPool.getMutants(); ExecutionResult origResult = runTest(test); Map<Mutation, ExecutionResult> mutationResults = new HashMap<Mutation, ExecutionResult>(); // execute on all mutants in the target method that were touched for (Mutation mutant : mutants) { if (!origResult.getTrace().wasMutationTouched(mutant.getId())) continue; if (!targetMethods.contains(mutant.getMethodName())) { continue; } ExecutionResult mutationResult = runTest(test, mutant); mutationResults.put(mutant, mutationResult); } addAssertions(structuredTest, origResult, mutationResults); }
private Map<Integer, Set<Integer>> getKillMap( List<Assertion> assertions, Map<Mutation, ExecutionResult> mutationResults) { Map<Integer, Set<Integer>> killMap = new HashMap<Integer, Set<Integer>>(); int num = 0; for (Assertion assertion : assertions) { Set<Integer> killedMutations = new HashSet<Integer>(); for (Mutation m : mutationResults.keySet()) { boolean isKilled = false; for (OutputTrace<?> trace : mutationResults.get(m).getTraces()) { if (trace.isDetectedBy(assertion)) { isKilled = true; break; } } if (isKilled) { killedMutations.add(m.getId()); assertion.addKilledMutation(m); } } killMap.put(num, killedMutations); num++; } return killMap; }