org.pitest.plugin.Feature Java Examples

The following examples show how to use org.pitest.plugin.Feature. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SettingsFactory.java    From pitest with Apache License 2.0 6 votes vote down vote up
public void describeFeatures(Consumer<Feature> enabled, Consumer<Feature> disabled) {
  final FeatureParser parser = new FeatureParser();
  final Collection<ProvidesFeature> available = new ArrayList<>(this.plugins.findInterceptors());
  final List<FeatureSetting> settings = parser.parseFeatures(this.options.getFeatures());
  final FeatureSelector<ProvidesFeature> selector = new FeatureSelector<>(settings, available);

  List<Feature> enabledFeatures = selector.getActiveFeatures().stream()
    .map(toFeature())
    .distinct()
    .sorted(byName())
    .collect(Collectors.toList());
    
  enabledFeatures.forEach(enabled);

  available.stream()
    .map(toFeature())
    .distinct()
    .sorted(byName())
    .filter(f -> !enabledFeatures.contains(f))
    .forEach(disabled);
  
}
 
Example #2
Source File: StopMethodMatcherInterceptorFactory.java    From pitest-descartes with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Feature provides() {
    return Feature
            .named("STOP_METHODS")
            .withOnByDefault(true)
            .withDescription("Filters out mutations in methods that are generally of no interest")
            .withParameter(EXCEPT);

}
 
Example #3
Source File: SettingsFactoryTest.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDescribeDisabledFeatures() {
  final Consumer<Feature> disabled = Mockito.mock(Consumer.class);
  final Consumer<Feature> enabled = Mockito.mock(Consumer.class);

  this.options.setFeatures(Arrays.asList("-FSTATINIT"));

  this.testee.describeFeatures(enabled, disabled);
  verify(enabled, never()).accept(Feature.named("FSTATINIT"));
  verify(disabled).accept(Feature.named("FSTATINIT"));
}
 
Example #4
Source File: SettingsFactoryTest.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldDescribeActiveFeatures() {
  final Consumer<Feature> disabled = Mockito.mock(Consumer.class);
  final Consumer<Feature> enabled = Mockito.mock(Consumer.class);

  this.options.setFeatures(Arrays.asList("+FSTATINIT"));

  this.testee.describeFeatures(enabled, disabled);
  verify(enabled).accept(Feature.named("FSTATINIT"));
  verify(disabled, never()).accept(Feature.named("FSTATINIT"));
}
 
Example #5
Source File: ExcludedAnnotationInterceptorFactory.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FANN")
      .withOnByDefault(true)
      .withDescription("Filters mutations in classes and methods with matching annotations of class or runtime retention")
      .withParameter(ARGUMENT);
}
 
Example #6
Source File: EquivalentReturnMutationFilter.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FRETEQUIV")
      .withOnByDefault(true)
      .withDescription("Filters return vals mutants with bytecode equivalent to the unmutated class");

}
 
Example #7
Source File: InfiniteIteratorLoopFilterFactory.java    From pitest with Apache License 2.0 5 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FINFIT")
      .withOnByDefault(true)
      .withDescription("Filters mutations that may cause infinite loops"
          + " by removing calls to iterator.next");
}
 
Example #8
Source File: AvoidNullInNotNullInterceptorTest.java    From pitest-descartes with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MutationInterceptor getInterceptor() {
    AvoidNullInNotNullInterceptorFactory factory = new AvoidNullInNotNullInterceptorFactory();
    Feature feature = factory.provides();
    FeatureSetting setting = new FeatureSetting(feature.name(), ToggleStatus.ACTIVATE, Collections.emptyMap());
    InterceptorParameters params = new InterceptorParameters(setting, null, null);
    return new AvoidNullInNotNullInterceptorFactory().createInterceptor(params);
}
 
Example #9
Source File: StopMethodInterceptorTest.java    From pitest-descartes with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MutationInterceptor getInterceptor(String... exclusions) throws IOException {
    StopMethodMatcherInterceptorFactory stopFactory = new StopMethodMatcherInterceptorFactory();
    Feature feature = stopFactory.provides();
    Map<String, List<String>> featureParameters = new HashMap<>();
    featureParameters.put("except", Arrays.asList(exclusions));
    FeatureSetting setting = new FeatureSetting(feature.name(), ToggleStatus.ACTIVATE, featureParameters);
    InterceptorParameters params = new InterceptorParameters(setting, null, null);
    return stopFactory.createInterceptor(params);
}
 
Example #10
Source File: EntryPoint.java    From pitest with Apache License 2.0 5 votes vote down vote up
private Consumer<Feature> asInfo(final String leader) {
  return a -> {
    Log.getLogger().info(String.format("%1$-16s",leader + a.name()) + a.description());
    for (final FeatureParameter each : a.params()) {
      Log.getLogger().info(String.format("%1$-18s", "  [" + each.name() + "]") + each.description());
    }
  };
}
 
Example #11
Source File: TryWithResourcesFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FTRYWR")
      .withOnByDefault(true)
      .withDescription("Filters mutations in code generated for try with resources statements");
}
 
Example #12
Source File: KotlinInterceptorFactory.java    From pitest-kotlin with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("KOTLIN")
    .withOnByDefault(true)
    .withDescription("Improves support of kotlin language");
}
 
Example #13
Source File: AvoidNullInNotNullInterceptorFactory.java    From pitest-descartes with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Feature provides() {
    return Feature.named("AVOID_NULL")
            .withDescription(DESCRIPTION)
            .withOnByDefault(true);
}
 
Example #14
Source File: LimitNumberOfMutationsPerClassFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("CLASSLIMIT")
      .withDescription("Limits the maximum number of mutations per class")
      .withParameter(this.limit);
}
 
Example #15
Source File: KotlinFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FKOTLIN")
      .withDescription("Filters out junk mutations in bytecode created by compiler for kotlin language features")
      .withOnByDefault(true);
}
 
Example #16
Source File: EqualsPerformanceShortcutFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FSEQUIVEQUALS")
      .withOnByDefault(true)
      .withDescription("Filters equivalent mutations that affect only performance in short cutting equals methods");
}
 
Example #17
Source File: AvoidForLoopCountersFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FFLOOP")
      .withOnByDefault(true)
      .withDescription("Filters any mutations to increments in for loops as they may cause timeouts");
}
 
Example #18
Source File: InfiniteForLoopFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FINFINC")
      .withOnByDefault(true)
      .withDescription("Filters mutations to increments that may cause infinite loops");
}
 
Example #19
Source File: MutantExportFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("EXPORT")
      .withDescription("Exports mutants bytecode and other details to disk")
      .withOnByDefault(false);
}
 
Example #20
Source File: ForEachLoopFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FFEACH")
      .withOnByDefault(true)
      .withDescription("Filters mutations in compiler generated code that implements for each loops");
}
 
Example #21
Source File: EnumConstructorFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
    return Feature.named("FENUM")
            .withOnByDefault(true)
            .withDescription("Filters mutations in enum constructors");
}
 
Example #22
Source File: ImplicitNullCheckFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FINULL")
      .withOnByDefault(true)
      .withDescription("Filters mutations in compiler generated code that checks for null by calling getClass");
}
 
Example #23
Source File: InlinedFinallyBlockFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FFBLOCK")
      .withOnByDefault(true)
      .withDescription("Filters mutations in code duplicated by finally block inlining");
}
 
Example #24
Source File: MethodReferenceNullCheckFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FMRNULL")
      .withOnByDefault(true)
      .withDescription("Filters mutations in compiler generated code that inserts Objects.requireNonNull for method references");
}
 
Example #25
Source File: LoggingCallsFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FLOGCALL")
      .withOnByDefault(true)
      .withDescription("Filters mutations in code that makes calls to logging frameworks");
}
 
Example #26
Source File: StaticInitializerInterceptorFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FSTATI")
      .withOnByDefault(true)
      .withDescription("Filters mutations in static initializers and code called only from them");
}
 
Example #27
Source File: StaticInitializerFilterFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
@Override
public Feature provides() {
  return Feature.named("FSTATINIT")
      .withOnByDefault(true)
      .withDescription("Filters mutations in static initializers and code called only from them");
}
 
Example #28
Source File: SettingsFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
private Comparator<Feature> byName() {
  return Comparator.comparing(Feature::name);
}
 
Example #29
Source File: SettingsFactory.java    From pitest with Apache License 2.0 4 votes vote down vote up
private static Function<ProvidesFeature, Feature> toFeature() {
  return a -> a.provides();
}