/** * Returns the class in which this mutation is located * * @return class in which mutation is located */ public MethodName getMethod() { return this.id.getLocation().getMethodName(); }
@Override public int compareTo(final Location o) { int comp = this.clazz.compareTo(o.getClassName()); if (comp != 0) { return comp; } comp = this.method.name().compareTo(o.getMethodName().name()); if (comp != 0) { return comp; } return this.methodDesc.compareTo(o.getMethodDesc()); }
private static Predicate<MutationDetails> isInStaticInitializer() { return a -> a.getId().getLocation().getMethodName().equals(CLINIT); }
private Predicate<MutationDetails> inEqualsMethod() { return a -> { final Location loc = a.getId().getLocation(); return loc.getMethodDesc().equals("(Ljava/lang/Object;)Z") && loc.getMethodName().equals(MethodName.fromString("equals")); }; }
@Override public boolean matches(MutationDetails value) { return value.getId().getLocation().getMethodName().name().equals(name); } };
@Test public void shouldFilterMethodsWithGeneratedAnnotation() { final List<MutationDetails> mutations = this.mutator.findMutations(ClassName.fromClass(MethodAnnotatedWithGenerated.class)); final Collection<MutationDetails> actual = runWithTestee(mutations, MethodAnnotatedWithGenerated.class); assertThat(actual).hasSize(1); assertThat(actual.iterator().next().getId().getLocation().getMethodName().name()).isEqualTo("bar"); }
private void assertOnlyClinitMethodsMarked(Collection<MutationDetails> actual) { for (final MutationDetails each : actual ) { if (each.isInStaticInitializer()) { if (!each.getId().getLocation().getMethodName().name().equals("<clinit>")) { fail("Expected no mutants to be marked as for static initialization but " + each + " was"); } } } }
private void writeLineCoverage(final BlockCoverage each, final Writer out) { final Location l = each.getBlock().getLocation(); write( out, "<block classname='" + l.getClassName().asJavaName() + "'" + " method='" + StringUtil.escapeBasicHtmlChars(l.getMethodName().name()) + StringUtil.escapeBasicHtmlChars(l.getMethodDesc()) + "' number='" + each.getBlock().getBlock() + "'>"); write(out, "<tests>\n"); final List<String> ts = new ArrayList<>(each.getTests()); Collections.sort(ts); for (final String test : ts) { write(out, "<test name='" + StringUtil.escapeBasicHtmlChars(test) + "'/>\n"); } write(out, "</tests>\n"); write(out, "</block>\n"); }
/** * Returns the class in which this mutation is located * * @return class in which mutation is located */ public MethodName getMethod() { return this.id.getLocation().getMethodName(); }
public String name() { return location.getMethodName().name(); }
private void updateStatus(DetectionStatus status) { if(status == DetectionStatus.NO_COVERAGE) { if(classification != NOT_COVERED) throw new IllegalArgumentException("Method " + location.getMethodName().name() + " has been marked as covered and can not accept a non-covered mutation."); return; } if(classification == NOT_COVERED) throw new IllegalArgumentException("Method " + location.getMethodName().name() + " has been marked as non-covered and can not accept a covered mutation"); if((status.isDetected() && classification == PSEUDO_TESTED) || (!status.isDetected() && classification == TESTED)) classification = PARTIALLY_TESTED; }
@Override public int compareTo(final Location o) { int comp = this.clazz.compareTo(o.getClassName()); if (comp != 0) { return comp; } comp = this.method.name().compareTo(o.getMethodName().name()); if (comp != 0) { return comp; } return this.methodDesc.compareTo(o.getMethodDesc()); }
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions); Location location = mID.getLocation(); if(location.getMethodDesc().equals(desc) && location.getMethodName().name().equals(name)) { return new MutationMethodAdapter( MutationOperator.fromID(mID.getMutator()), new Method(location.getMethodName().name(), location.getMethodDesc()), methodVisitor); } return methodVisitor; } }