Search in sources :

Example 1 with Keywords

use of org.jbehave.core.configuration.Keywords 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);
}
Also used : Locale(java.util.Locale) StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) Keywords(org.jbehave.core.configuration.Keywords) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) RegexStoryParser(org.jbehave.core.parsers.RegexStoryParser) Configuration(org.jbehave.core.configuration.Configuration) FreemarkerViewGenerator(org.jbehave.core.reporters.FreemarkerViewGenerator) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) Properties(java.util.Properties) MarkUnmatchedStepsAsPending(org.jbehave.core.steps.MarkUnmatchedStepsAsPending)

Example 2 with Keywords

use of org.jbehave.core.configuration.Keywords 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 3 with Keywords

use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.

the class StepCreatorBehaviour method shouldCreatePendingAsStepResults.

@Test
public void shouldCreatePendingAsStepResults() {
    // When
    String stepAsString = "When I'm pending";
    Step pendingStep = StepCreator.createPendingStep(stepAsString, null);
    // Then
    assertThat(pendingStep.asString(new Keywords()), equalTo(stepAsString));
    assertThat(pendingStep.perform(null), instanceOf(Pending.class));
    assertThat(pendingStep.doNotPerform(null), instanceOf(Pending.class));
}
Also used : Keywords(org.jbehave.core.configuration.Keywords) Matchers.anyString(org.mockito.Matchers.anyString) ParametrisedStep(org.jbehave.core.steps.StepCreator.ParametrisedStep) Pending(org.jbehave.core.steps.AbstractStepResult.Pending) Test(org.junit.Test)

Example 4 with Keywords

use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.

the class StepCreatorBehaviour method shouldCreateCommentAsStepResults.

@Test
public void shouldCreateCommentAsStepResults() {
    // When
    String stepAsString = "!-- A comment";
    Step comment = StepCreator.createComment(stepAsString);
    // Then
    assertThat(comment.asString(new Keywords()), equalTo(stepAsString));
    assertThat(comment.perform(null), instanceOf(Comment.class));
    assertThat(comment.doNotPerform(null), instanceOf(Comment.class));
}
Also used : Comment(org.jbehave.core.steps.AbstractStepResult.Comment) Keywords(org.jbehave.core.configuration.Keywords) Matchers.anyString(org.mockito.Matchers.anyString) ParametrisedStep(org.jbehave.core.steps.StepCreator.ParametrisedStep) Test(org.junit.Test)

Example 5 with Keywords

use of org.jbehave.core.configuration.Keywords in project jbehave-core by jbehave.

the class StepCreatorBehaviour method shouldCreateIgnorableAsStepResults.

@Test
public void shouldCreateIgnorableAsStepResults() {
    // When
    String stepAsString = "!-- Then ignore me";
    Step ignorableStep = StepCreator.createIgnorableStep(stepAsString);
    // Then
    assertThat(ignorableStep.asString(new Keywords()), equalTo(stepAsString));
    assertThat(ignorableStep.perform(null), instanceOf(Ignorable.class));
    assertThat(ignorableStep.doNotPerform(null), instanceOf(Ignorable.class));
}
Also used : Keywords(org.jbehave.core.configuration.Keywords) Ignorable(org.jbehave.core.steps.AbstractStepResult.Ignorable) Matchers.anyString(org.mockito.Matchers.anyString) ParametrisedStep(org.jbehave.core.steps.StepCreator.ParametrisedStep) Test(org.junit.Test)

Aggregations

Keywords (org.jbehave.core.configuration.Keywords)18 Test (org.junit.Test)12 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)9 Locale (java.util.Locale)4 Properties (java.util.Properties)4 Configuration (org.jbehave.core.configuration.Configuration)4 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)4 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)4 SimpleDateFormat (java.text.SimpleDateFormat)3 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)3 LoadFromURL (org.jbehave.core.io.LoadFromURL)3 ParametrisedStep (org.jbehave.core.steps.StepCreator.ParametrisedStep)3 Matchers.anyString (org.mockito.Matchers.anyString)3 URL (java.net.URL)2 AnnotationBuilder (org.jbehave.core.configuration.AnnotationBuilder)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 Meta (org.jbehave.core.model.Meta)2 TableTransformers (org.jbehave.core.model.TableTransformers)2 RegexStoryParser (org.jbehave.core.parsers.RegexStoryParser)2 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)2