Search in sources :

Example 1 with StepsContext

use of org.jbehave.core.steps.context.StepsContext 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 StepsContext

use of org.jbehave.core.steps.context.StepsContext in project jbehave-core by jbehave.

the class StepCandidateBehaviour method candidateWith.

private StepCandidate candidateWith(String patternAsString, StepType stepType, Method method, Object instance, ParameterControls parameterControls) {
    Class<?> stepsType = instance.getClass();
    MostUsefulConfiguration configuration = new MostUsefulConfiguration();
    InjectableStepsFactory stepsFactory = new InstanceStepsFactory(configuration, instance);
    return new StepCandidate(patternAsString, 0, stepType, method, stepsType, stepsFactory, new StepsContext(), keywords, new RegexPrefixCapturingPatternParser(), configuration.parameterConverters(), parameterControls);
}
Also used : StepsContext(org.jbehave.core.steps.context.StepsContext) RegexPrefixCapturingPatternParser(org.jbehave.core.parsers.RegexPrefixCapturingPatternParser) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration)

Aggregations

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