@Test public void shouldParseFeatureWithDocstring() throws IOException { List<Feature> features = FeatureParser.parse("target/test-classes/json-output/parser/feature_with_docstring.json"); assertThat(features).hasSize(1).contains(FeatureBuilder.instance().name("An embed data directly feature").id("an-embed-data-directly-feature").build()); List<Scenario> scenarios = features.get(0).getScenarios(); assertNotNull(scenarios); for (Scenario scenario : scenarios) { if(scenario.getName().equals("scenario 1")){ Step step = scenario.getStepByName("I embed data directly"); assertThat(step).isNotNull(); assertThat(step.getDocString()).isNotNull(); assertThat(step.getDocString().getValue()).isEqualTo("A paragraph in an open block."); assertThat(step.getDocString().getContentType()).isEqualTo(""); step = scenario.getStepByName("I embed code directly"); assertThat(step).isNotNull(); assertThat(step.getDocString()).isNotNull(); assertThat(step.getDocString().getValue()).isEqualTo("puts('Hello world')"); assertThat(step.getDocString().getContentType()).isEqualTo("ruby"); } } }
public static List<Feature> parse(String json) { List<Feature> features = null; try (InputStreamReader is = new InputStreamReader(new FileInputStream(json),"UTF-8")) { features = new ObjectMapper().readValue(is, new TypeReference<List<Feature>>() { }); Iterator<Feature> it = features.iterator(); while (it.hasNext()) { Feature feature = it.next(); if (!feature.isCucumberFeature()) { log.warning("json:" + json + " is NOT a Cucumber feature result file and will be ignored"); it.remove(); }else{ feature.initScenarios(); feature.processSteps(); } } } catch (FileNotFoundException e) { log.log(Level.WARNING, "Could not find json file:" + json); } catch (JsonMappingException e) { log.log(Level.WARNING, "Could not map json file:" + json); } catch (JsonParseException e) { log.log(Level.WARNING, "Could not parse json file:" + json); } catch (IOException e) { log.log(Level.WARNING, "Could not read json file:" + json); } return features; }
FeatureParser { public static List<Feature> parse(String json) { List<Feature> features = null; try (InputStreamReader is = new InputStreamReader(new FileInputStream(json),"UTF-8")) { features = new ObjectMapper().readValue(is, new TypeReference<List<Feature>>() { }); Iterator<Feature> it = features.iterator(); while (it.hasNext()) { Feature feature = it.next(); if (!feature.isCucumberFeature()) { log.warning("json:" + json + " is NOT a Cucumber feature result file and will be ignored"); it.remove(); }else{ feature.initScenarios(); feature.processSteps(); } } } catch (FileNotFoundException e) { log.log(Level.WARNING, "Could not find json file:" + json); } catch (JsonMappingException e) { log.log(Level.WARNING, "Could not map json file:" + json); } catch (JsonParseException e) { log.log(Level.WARNING, "Could not parse json file:" + json); } catch (IOException e) { log.log(Level.WARNING, "Could not read json file:" + json); } return features; } }
FeatureParser { public static List<Feature> parse(String json) { List<Feature> features = null; try (InputStreamReader is = new InputStreamReader(new FileInputStream(json),"UTF-8")) { features = new ObjectMapper().readValue(is, new TypeReference<List<Feature>>() { }); Iterator<Feature> it = features.iterator(); while (it.hasNext()) { Feature feature = it.next(); if (!feature.isCucumberFeature()) { log.warning("json:" + json + " is NOT a Cucumber feature result file and will be ignored"); it.remove(); }else{ feature.initScenarios(); feature.processSteps(); } } } catch (FileNotFoundException e) { log.log(Level.WARNING, "Could not find json file:" + json); } catch (JsonMappingException e) { log.log(Level.WARNING, "Could not map json file:" + json); } catch (JsonParseException e) { log.log(Level.WARNING, "Could not parse json file:" + json); } catch (IOException e) { log.log(Level.WARNING, "Could not read json file:" + json); } return features; }  }
FeatureParser { public static List<Feature> parse(String json) { List<Feature> features = null; try (InputStreamReader is = new InputStreamReader(new FileInputStream(json),"UTF-8")) { features = new ObjectMapper().readValue(is, new TypeReference<List<Feature>>() { }); Iterator<Feature> it = features.iterator(); while (it.hasNext()) { Feature feature = it.next(); if (!feature.isCucumberFeature()) { log.warning("json:" + json + " is NOT a Cucumber feature result file and will be ignored"); it.remove(); }else{ feature.initScenarios(); feature.processSteps(); } } } catch (FileNotFoundException e) { log.log(Level.WARNING, "Could not find json file:" + json); } catch (JsonMappingException e) { log.log(Level.WARNING, "Could not map json file:" + json); } catch (JsonParseException e) { log.log(Level.WARNING, "Could not parse json file:" + json); } catch (IOException e) { log.log(Level.WARNING, "Could not read json file:" + json); } return features; }  static List<Feature> parse(String json); static List<Feature> parse(List<String> paths); static List<Feature> parse(String... paths); static List<Feature> findAndParse(String basePath); }
FeatureParser { public static List<Feature> parse(String json) { List<Feature> features = null; try (InputStreamReader is = new InputStreamReader(new FileInputStream(json),"UTF-8")) { features = new ObjectMapper().readValue(is, new TypeReference<List<Feature>>() { }); Iterator<Feature> it = features.iterator(); while (it.hasNext()) { Feature feature = it.next(); if (!feature.isCucumberFeature()) { log.warning("json:" + json + " is NOT a Cucumber feature result file and will be ignored"); it.remove(); }else{ feature.initScenarios(); feature.processSteps(); } } } catch (FileNotFoundException e) { log.log(Level.WARNING, "Could not find json file:" + json); } catch (JsonMappingException e) { log.log(Level.WARNING, "Could not map json file:" + json); } catch (JsonParseException e) { log.log(Level.WARNING, "Could not parse json file:" + json); } catch (IOException e) { log.log(Level.WARNING, "Could not read json file:" + json); } return features; }  static List<Feature> parse(String json); static List<Feature> parse(List<String> paths); static List<Feature> parse(String... paths); static List<Feature> findAndParse(String basePath);  }