use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class CoreStories method configuration.
@Override
public Configuration configuration() {
// alternative use #useConfiguration() in the constructor
if (super.hasConfiguration()) {
return super.configuration();
}
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
viewResources.put("reports", "ftl/jbehave-reports.ftl");
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external
// resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withViewResources(viewResources).withFormats(contextFormat, CONSOLE, TXT, HTML_TEMPLATE, XML_TEMPLATE).withFailureTrace(true).withFailureTraceCompression(true).withCrossReference(xref).withSurefireReporter(new SurefireReporter(embeddableClass))).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class CustomCoreStories method configuration.
@Override
public Configuration configuration() {
Configuration configuration = super.configuration();
Properties viewResources = new Properties();
viewResources.put("reports", "ftl/custom-reports.ftl");
configuration.useViewGenerator(new FreemarkerViewGenerator(this.getClass()));
Keywords keywords = new LocalizedKeywords(new Locale("en"), "i18n/custom", "i18n/keywords", this.getClass().getClassLoader());
StoryReporterBuilder reporterBuilder = configuration.storyReporterBuilder().withKeywords(keywords).withViewResources(viewResources).withFormats(CustomHtmlOutput.FORMAT);
return configuration.useKeywords(keywords).useStepCollector(new MarkUnmatchedStepsAsPending(keywords)).useStoryParser(new RegexStoryParser(keywords)).useStoryReporterBuilder(reporterBuilder);
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithSynonymsOfStartingWords.
@Test
public void shouldParseStoryWithSynonymsOfStartingWords() {
StoryParser parser = new RegexStoryParser(new LocalizedKeywords(new Locale("sy")));
String wholeStory = "Given a scenario" + NL + "When I parse it" + NL + "And I parse it again" + NL + "With another parse as well" + NL + "!-- ignore me" + NL + "Giveth another scenario" + NL + "With a merry go round";
Story story = parser.parseStory(wholeStory, storyPath);
List<String> steps = story.getScenarios().get(0).getSteps();
assertThat(steps.get(0), equalTo("Given a scenario"));
assertThat(steps.get(1), equalTo("When I parse it"));
assertThat(steps.get(2), equalTo("And I parse it again"));
assertThat(steps.get(3), equalTo("With another parse as well"));
assertThat(steps.get(4), equalTo("!-- ignore me"));
assertThat(steps.get(5), equalTo("Giveth another scenario"));
assertThat(steps.get(6), equalTo("With a merry go round"));
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class CrossReferenceBehaviour method performableRoot.
private PerformableRoot performableRoot() {
PerformableRoot root = new PerformableRoot();
Story story = new Story("/path/to/story", new Description("An interesting story"), new Meta(Arrays.asList("+theme testing", "+author Mauro")), new Narrative("renovate my house", "customer", "get a loan"), new ArrayList<Scenario>());
PerformableStory performableStory = new PerformableStory(story, new LocalizedKeywords(), false);
root.add(performableStory);
Scenario scenario = new Scenario(Arrays.asList(""));
PerformableScenario performableScenario = new PerformableScenario(scenario, story.getPath());
performableStory.add(performableScenario);
List<StepMatch> stepMatches = new ArrayList<>();
stepMatches.add(new StepMatch(new StepPattern(StepType.GIVEN, "(def)", "[abc]")));
NormalPerformableScenario normalScenario = new NormalPerformableScenario(scenario);
normalScenario.addSteps(new PerformableSteps(null, stepMatches));
performableScenario.useNormalScenario(normalScenario);
return root;
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class StepCandidateBehaviour method shouldNotMatchOrIgnoreStepWhenStartingWordNotFound.
@Test
public void shouldNotMatchOrIgnoreStepWhenStartingWordNotFound() throws Exception {
Method method = SomeSteps.class.getMethod("aMethod");
Keywords keywords = new LocalizedKeywords() {
@Override
public String startingWordFor(StepType stepType) {
throw new StartingWordNotFound(stepType, new HashMap<StepType, String>());
}
};
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath(), new TableTransformers());
StepCandidate candidate = new StepCandidate("windows on the $nth floor", 0, WHEN, method, null, null, new StepsContext(), keywords, new RegexPrefixCapturingPatternParser(), parameterConverters, new ParameterControls());
assertThat(candidate.matches("When windows on the 1st floor"), is(false));
assertThat(candidate.ignore("!-- windows on the 1st floor"), is(false));
}
Aggregations