use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAfterUponOutcomeAndMetaFilter.
@Test
public void shouldParseStoryWithLifecycleAfterUponOutcomeAndMetaFilter() {
String wholeStory = "Lifecycle: " + NL + "After:" + NL + NL + "Outcome: ANY " + NL + "MetaFilter: +all" + NL + "Given a step after any scenario" + NL + "Outcome: SUCCESS " + NL + "MetaFilter: +happy" + NL + "Given a step after successful scenario" + NL + "Outcome: FAILURE " + NL + "MetaFilter: +sad" + NL + "Given a step after failed scenario" + NL + "Scenario:" + NL + "Given a scenario";
Story story = parser.parseStory(wholeStory, storyPath);
List<String> beforeSteps = story.getLifecycle().getBeforeSteps();
assertThat(beforeSteps.isEmpty(), equalTo(true));
Lifecycle lifecycle = story.getLifecycle();
List<String> afterSteps = lifecycle.getAfterSteps();
assertThat(afterSteps.get(0), equalTo("Given a step after any scenario"));
assertThat(afterSteps.get(1), equalTo("Given a step after successful scenario"));
assertThat(afterSteps.get(2), equalTo("Given a step after failed scenario"));
assertThat(new ArrayList<>(lifecycle.getOutcomes()), equalTo(Arrays.asList(Outcome.ANY, Outcome.SUCCESS, Outcome.FAILURE)));
assertThat(lifecycle.getAfterSteps(Outcome.ANY).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.ANY).get(0), equalTo("Given a step after any scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).get(0), equalTo("Given a step after successful scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).get(0), equalTo("Given a step after failed scenario"));
assertThat(lifecycle.getMetaFilter(Outcome.ANY).asString(), equalTo("+all"));
Keywords keywords = new Keywords();
assertThat(lifecycle.getAfterSteps(Outcome.ANY, Meta.createMeta("@all", keywords)).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.ANY, Meta.createMeta("@all", keywords)).get(0), equalTo("Given a step after any scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.ANY, Meta.createMeta("@none", keywords)).size(), equalTo(0));
assertThat(lifecycle.getMetaFilter(Outcome.SUCCESS).asString(), equalTo("+happy"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS, Meta.createMeta("@happy", keywords)).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS, Meta.createMeta("@happy", keywords)).get(0), equalTo("Given a step after successful scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS, Meta.createMeta("@none", keywords)).size(), equalTo(0));
assertThat(lifecycle.getMetaFilter(Outcome.FAILURE).asString(), equalTo("+sad"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE, Meta.createMeta("@sad", keywords)).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE, Meta.createMeta("@sad", keywords)).get(0), equalTo("Given a step after failed scenario"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE, Meta.createMeta("@none", keywords)).size(), equalTo(0));
Scenario scenario = story.getScenarios().get(0);
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario"));
}
use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.
the class LocalizedKeywordsBehaviour method shouldAllowSynonymsToOverrideABaseBundleForSameLocale.
@Test
public void shouldAllowSynonymsToOverrideABaseBundleForSameLocale() throws IOException {
Keywords keywords = new LocalizedKeywords(new Locale("en"), "i18n/synonyms", "i18n/keywords");
assertThat(keywords.given(), equalTo("Given|Giveth"));
assertThat(keywords.and(), equalTo("And|With"));
}
use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.
the class LocalizedKeywordsBehaviour method ensureKeywordsAreLocalised.
private void ensureKeywordsAreLocalised(Configuration configuration, Locale locale) {
Keywords keywords = keywordsFor(locale, null, null);
Map<StepType, String> startingWordsByType = keywords.startingWordsByType();
assertThat(startingWordsByType.get(StepType.GIVEN), equalTo(keywords.given()));
assertThat(startingWordsByType.get(StepType.WHEN), equalTo(keywords.when()));
assertThat(startingWordsByType.get(StepType.THEN), equalTo(keywords.then()));
assertThat(startingWordsByType.get(StepType.AND), equalTo(keywords.and()));
assertThat(startingWordsByType.get(StepType.IGNORABLE), equalTo(keywords.ignorable()));
}
use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.
the class LocalizedKeywordsBehaviour method ensureKeywordsAreLocalisedFor.
private void ensureKeywordsAreLocalisedFor(Locale locale, Locale baseLocale, String bundleName) throws IOException {
Keywords keywords = keywordsFor(locale, baseLocale, bundleName, null);
Properties properties = bundleFor(locale);
ensureKeywordIs(properties, META, keywords.meta());
ensureKeywordIs(properties, META_PROPERTY, keywords.metaProperty());
ensureKeywordIs(properties, NARRATIVE, keywords.narrative());
ensureKeywordIs(properties, IN_ORDER_TO, keywords.inOrderTo());
ensureKeywordIs(properties, AS_A, keywords.asA());
ensureKeywordIs(properties, I_WANT_TO, keywords.iWantTo());
ensureKeywordIs(properties, SO_THAT, keywords.soThat());
ensureKeywordIs(properties, SCENARIO, keywords.scenario());
ensureKeywordIs(properties, GIVEN_STORIES, keywords.givenStories());
ensureKeywordIs(properties, LIFECYCLE, keywords.lifecycle());
ensureKeywordIs(properties, BEFORE, keywords.before());
ensureKeywordIs(properties, AFTER, keywords.after());
ensureKeywordIs(properties, EXAMPLES_TABLE, keywords.examplesTable());
ensureKeywordIs(properties, EXAMPLES_TABLE_ROW, keywords.examplesTableRow());
ensureKeywordIs(properties, EXAMPLES_TABLE_HEADER_SEPARATOR, keywords.examplesTableHeaderSeparator());
ensureKeywordIs(properties, EXAMPLES_TABLE_VALUE_SEPARATOR, keywords.examplesTableValueSeparator());
ensureKeywordIs(properties, EXAMPLES_TABLE_IGNORABLE_SEPARATOR, keywords.examplesTableIgnorableSeparator());
ensureKeywordIs(properties, GIVEN, keywords.given());
ensureKeywordIs(properties, WHEN, keywords.when());
ensureKeywordIs(properties, THEN, keywords.then());
ensureKeywordIs(properties, AND, keywords.and());
ensureKeywordIs(properties, IGNORABLE, keywords.ignorable());
ensureKeywordIs(properties, PENDING, keywords.pending());
ensureKeywordIs(properties, NOT_PERFORMED, keywords.notPerformed());
ensureKeywordIs(properties, FAILED, keywords.failed());
ensureKeywordIs(properties, DRY_RUN, keywords.dryRun());
ensureKeywordIs(properties, STORY_CANCELLED, keywords.storyCancelled());
ensureKeywordIs(properties, SCOPE, keywords.scope());
ensureKeywordIs(properties, SCOPE_SCENARIO, keywords.scopeScenario());
ensureKeywordIs(properties, SCOPE_STORY, keywords.scopeStory());
ensureKeywordIs(properties, META_FILTER, keywords.metaFilter());
ensureKeywordIs(properties, OUTCOME, keywords.outcome());
ensureKeywordIs(properties, OUTCOME_ANY, keywords.outcomeAny());
ensureKeywordIs(properties, OUTCOME_SUCCESS, keywords.outcomeSuccess());
ensureKeywordIs(properties, OUTCOME_FAILURE, keywords.outcomeFailure());
ensureKeywordIs(properties, OUTCOME_DESCRIPTION, keywords.outcomeDescription());
ensureKeywordIs(properties, OUTCOME_VALUE, keywords.outcomeValue());
ensureKeywordIs(properties, OUTCOME_MATCHER, keywords.outcomeMatcher());
ensureKeywordIs(properties, OUTCOME_VERIFIED, keywords.outcomeVerified());
}
use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.
the class LocalizedKeywordsBehaviour method shouldAllowSynonymsToOverrideABaseLocale.
@Test
public void shouldAllowSynonymsToOverrideABaseLocale() throws IOException {
Keywords keywords = new LocalizedKeywords(new Locale("sy"), Locale.ENGLISH);
assertThat(keywords.given(), equalTo("Given|Giveth"));
assertThat(keywords.and(), equalTo("And|With"));
}
Aggregations