### Question:
FeatureFilter { public List<Feature> filter(String text) { List<Feature> features = new ArrayList<Feature>(); for (Feature feature : this.features) { Feature result =this.getMatch(feature, text); if (result != null) { features.add(feature); } } return features; } FeatureFilter(List<Feature> features); List<Feature> filter(String text); static boolean isMatch(Feature feature, String text); static List<String> getGroupTags(String text); static Pattern TAG_PATTERN; }### Answer:
@Test public void filterTagReduceScenarioTest() { PerfRuntimeOptions options = new PerfRuntimeOptions(Arrays.asList(new String[] {"-g steps","src/test/java/resources"})); List<Feature> features = FeatureBuilder.getFeatures(FeatureBuilder.createRuntimeOptions(options.getCucumberOptions())); FeatureFilter filter = new FeatureFilter(features); List<Feature> ffs = filter.filter("@onlyfilter1"); assertEquals(ffs.get(0).getPickles().size(),1); }
@Test public void filterTagTest() { PerfRuntimeOptions options = new PerfRuntimeOptions(Arrays.asList(new String[] {"-g steps","src/test/java/resources"})); List<Feature> features = FeatureBuilder.getFeatures(FeatureBuilder.createRuntimeOptions(options.getCucumberOptions())); FeatureFilter filter = new FeatureFilter(features); List<Feature> ffs = filter.filter("@onlyfilter"); assertEquals(ffs.get(0).getPickles().size(),2); }
@Test public void filterMultiTagTest() { PerfRuntimeOptions options = new PerfRuntimeOptions(Arrays.asList(new String[] {"-g steps","src/test/java/resources"})); List<Feature> features = FeatureBuilder.getFeatures(FeatureBuilder.createRuntimeOptions(options.getCucumberOptions())); FeatureFilter filter = new FeatureFilter(features); List<Feature> ffs = filter.filter("@onlyfilter or @only"); assertEquals(ffs.size(),2); assertEquals(ffs.get(0).getPickles().size(),2); assertEquals(ffs.get(1).getPickles().size(),2); }
@Test public void filterNameTest() { PerfRuntimeOptions options = new PerfRuntimeOptions(Arrays.asList(new String[] {"-g steps","src/test/java/resources"})); List<Feature> features = FeatureBuilder.getFeatures(FeatureBuilder.createRuntimeOptions(options.getCucumberOptions())); FeatureFilter filter = new FeatureFilter(features); List<Feature> ffs = filter.filter("test.feature"); assertEquals(ffs.get(0).getName(),"test"); assertEquals(ffs.get(0).getPickles().size(),4); }