Search in sources :

Example 1 with StepType

use of org.jbehave.core.steps.StepType 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));
}
Also used : Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) StartingWordNotFound(org.jbehave.core.configuration.Keywords.StartingWordNotFound) StepType(org.jbehave.core.steps.StepType) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Method(java.lang.reflect.Method) TableTransformers(org.jbehave.core.model.TableTransformers) StepsContext(org.jbehave.core.steps.context.StepsContext) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) Test(org.junit.Test)

Example 2 with StepType

use of org.jbehave.core.steps.StepType 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()));
}
Also used : Keywords(org.jbehave.core.configuration.Keywords) StepType(org.jbehave.core.steps.StepType)

Aggregations

Keywords (org.jbehave.core.configuration.Keywords)2 StepType (org.jbehave.core.steps.StepType)2 Method (java.lang.reflect.Method)1 StartingWordNotFound (org.jbehave.core.configuration.Keywords.StartingWordNotFound)1 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)1 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)1 TableTransformers (org.jbehave.core.model.TableTransformers)1 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)1 StepsContext (org.jbehave.core.steps.context.StepsContext)1 Test (org.junit.Test)1