private static Predicate<MutationDetails> hasNoCoverage() { return a -> a.getTestsInOrder().isEmpty(); }
private Function<MutationResult, Iterable<TestInfo>> mutationToTargettedTests() { return a -> a.getDetails().getTestsInOrder(); }
private static Function<MutationDetails, Iterable<ClassName>> mutationDetailsToTestClass() { return a -> FCollection.map(a.getTestsInOrder(), TestInfo.toDefiningClassName()); }
@Test public void shouldAssignTestsFromPrioritiserToMutant() { final List<TestInfo> expected = makeTestInfos(0); final List<MutationDetails> mutations = makeMutations("foo"); when(this.prioritiser.assignTests(any(MutationDetails.class))).thenReturn( expected); when(this.mutater.findMutations(any(ClassName.class))) .thenReturn(mutations); final MutationDetails actual = this.testee.createMutations(this.foo) .iterator().next(); assertEquals(expected, actual.getTestsInOrder()); }
private void processMutation(final Reporter r, final TimeOutDecoratedTestSource testSource, final MutationDetails mutationDetails) throws IOException { final MutationIdentifier mutationId = mutationDetails.getId(); final Mutant mutatedClass = this.mutater.getMutation(mutationId); // For the benefit of mocking frameworks such as PowerMock // mess with the internals of Javassist so our mutated class // bytes are returned JavassistInterceptor.setMutant(mutatedClass); if (DEBUG) { LOG.fine("mutating method " + mutatedClass.getDetails().getMethod()); } final List<TestUnit> relevantTests = testSource .translateTests(mutationDetails.getTestsInOrder()); r.describe(mutationId); final MutationStatusTestPair mutationDetected = handleMutation( mutationDetails, mutatedClass, relevantTests); r.report(mutationId, mutationDetected); if (DEBUG) { LOG.fine("Mutation " + mutationId + " detected = " + mutationDetected); } }
public Collection<TestInfo> getTests() { return mutationResults.stream() .flatMap( (mutation) -> mutation.getDetails().getTestsInOrder().stream()) .collect(toSet()); }
private String makeTestInfoNode(MutationDetails aDetails) { List<TestInfo> tests = aDetails.getTestsInOrder(); if (tests == null || tests.isEmpty()) { return ""; } StringBuilder result = new StringBuilder(); for (TestInfo info : tests) { result.append(makeNode(info.getName(), Tag.testInfo)); } return makeNode(result.toString(), Tag.testInfos); }
private void processMutation(final Reporter r, final TimeOutDecoratedTestSource testSource, final MutationDetails mutationDetails) throws IOException { final MutationIdentifier mutationId = mutationDetails.getId(); final Mutant mutatedClass = this.mutater.getMutation(mutationId); // For the benefit of mocking frameworks such as PowerMock // mess with the internals of Javassist so our mutated class // bytes are returned JavassistInterceptor.setMutant(mutatedClass); if (DEBUG) { LOG.fine("mutating method " + mutatedClass.getDetails().getMethod()); } final List<TestUnit> relevantTests = testSource .translateTests(mutationDetails.getTestsInOrder()); r.describe(mutationId); final MutationStatusTestPair mutationDetected = handleMutation( mutationDetails, mutatedClass, relevantTests); r.report(mutationId, mutationDetected); if (DEBUG) { LOG.fine("Mutation " + mutationId + " detected = " + mutationDetected); } }
private void writeMutationDetails(MutationResult mutation) { try { report.beginObject(); report.writeAttribute("status", mutation.getStatus().name()); report.writeAttribute("mutator", mutation.getDetails().getMutator()); report.writeAttribute("tests-run", mutation.getNumberOfTestsRun()); report.writeAttribute("detected-by", mutation.getKillingTest().orElse("")); report.beginListAttribute("tests"); for (TestInfo test : mutation.getDetails().getTestsInOrder()) report.write(test.getName()); report.endList(); report.endObject(); } catch (IOException exc) { throw Unchecked.translateCheckedException(exc); } }
details.getTestsInOrder()) { report.write(info.getName());