use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class StoryReporterBuilderBehaviour method shouldBuildWithReporterOfDifferentFormats.
private void shouldBuildWithReporterOfDifferentFormats(StoryReporterBuilder builder) {
// Given
String storyPath = storyPath(MyStory.class);
Locale locale = Locale.getDefault();
// When
Format[] formats = { CONSOLE, IDE_CONSOLE, HTML, STATS, TXT, XML, JSON };
StoryReporter reporter = builder.withDefaultFormats().withFormats(formats).withKeywords(new LocalizedKeywords(locale)).build(storyPath);
// Then
assertThat(builder.formats(), hasItems(CONSOLE, IDE_CONSOLE, HTML, STATS, TXT, XML, JSON));
String[] upperCaseNames = new String[] { "CONSOLE", "IDE_CONSOLE", "HTML", "STATS", "TXT", "XML", "JSON" };
assertThat(builder.formatNames(false), hasItems(upperCaseNames));
String[] lowerCaseNames = new String[formats.length];
for (int i = 0; i < upperCaseNames.length; i++) {
lowerCaseNames[i] = upperCaseNames[i].toLowerCase(locale);
}
assertThat(builder.formatNames(true), hasItems(lowerCaseNames));
assertThat(reporter, instanceOf(ConcurrentStoryReporter.class));
StoryReporter delegate = ((ConcurrentStoryReporter) reporter).getDelegate();
assertThat(delegate, instanceOf(DelegatingStoryReporter.class));
Collection<StoryReporter> delegates = ((DelegatingStoryReporter) delegate).getDelegates();
assertThat(delegates.size(), equalTo(formats.length));
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class SurefireReporterBehaviour 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 SpringAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotations.
@Test
public void shouldBuildConfigurationFromAnnotations() {
SpringAnnotationBuilder builder = new SpringAnnotationBuilder(AnnotatedUsingSpring.class);
Configuration configuration = builder.buildConfiguration();
assertThat(configuration.storyControls().dryRun(), is(true));
assertThat(configuration.storyControls().skipScenariosAfterFailure(), is(true));
assertThat(configuration.failureStrategy(), instanceOf(SilentlyAbsorbingFailure.class));
assertThat(configuration.storyLoader(), instanceOf(LoadFromURL.class));
assertThat(configuration.stepPatternParser(), instanceOf(RegexPrefixCapturingPatternParser.class));
assertThat(((RegexPrefixCapturingPatternParser) configuration.stepPatternParser()).getPrefix(), equalTo("MyPrefix"));
assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
assertThat(configuration.parameterControls().nameDelimiterLeft(), equalTo("["));
assertThat(configuration.parameterControls().nameDelimiterRight(), equalTo("]"));
assertThat(configuration.storyReporterBuilder().formats(), hasItems(CONSOLE, HTML, TXT, XML, STATS));
Keywords keywords = configuration.storyReporterBuilder().keywords();
assertThat(keywords, instanceOf(LocalizedKeywords.class));
assertThat(((LocalizedKeywords) keywords).getLocale(), equalTo(Locale.ITALIAN));
assertThat(configuration.storyReporterBuilder().outputDirectory().getName(), equalTo("my-output-directory"));
assertThat(configuration.storyReporterBuilder().viewResources().getProperty("index"), equalTo("my-reports-index.ftl"));
assertThat(configuration.storyReporterBuilder().viewResources().getProperty("decorateNonHtml"), equalTo("true"));
assertThat(configuration.storyReporterBuilder().reportFailureTrace(), is(true));
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class SpringStoryReporterBuilderBehaviour method shouldAllowUseOfGettersAndSetters.
@Test
public void shouldAllowUseOfGettersAndSetters() {
SpringStoryReporterBuilder builder = new SpringStoryReporterBuilder();
URL codeLocation = CodeLocations.codeLocationFromClass(this.getClass());
builder.setCodeLocation(codeLocation);
assertThat(builder.getCodeLocation(), equalTo(codeLocation));
List<Format> formats = asList(Format.CONSOLE, Format.HTML);
builder.setFormats(formats);
assertThat(builder.getFormats(), equalTo(formats));
Keywords keywords = new LocalizedKeywords();
builder.setKeywords(keywords);
assertThat(builder.getKeywords(), equalTo(keywords));
String relativeDirectory = "reports";
builder.setRelativeDirectory(relativeDirectory);
assertThat(builder.getRelativeDirectory(), equalTo(relativeDirectory));
assertThat(builder.getOutputDirectory(), endsWith(relativeDirectory));
Properties viewResources = new Properties();
builder.setViewResources(viewResources);
assertThat(builder.getViewResources(), equalTo(viewResources));
boolean reportFailureTrace = true;
builder.setReportFailureTrace(reportFailureTrace);
assertThat(builder.isReportFailureTrace(), equalTo(reportFailureTrace));
FilePathResolver pathResolver = new FileConfiguration().getPathResolver();
builder.setPathResolver(pathResolver);
assertThat(builder.getPathResolver(), equalTo(pathResolver));
}
use of org.jbehave.core.i18n.LocalizedKeywords in project jbehave-core by jbehave.
the class ConfigurationProducer method getConfiguration.
@Produces
@WeldConfiguration
Configuration getConfiguration() {
Properties viewResources = new Properties();
viewResources.setProperty("index", "my-reports-index.ftl");
viewResources.setProperty("decorateNonHtml", "true");
TableTransformers tableTransformers = new TableTransformers();
LoadFromURL resourceLoader = new LoadFromURL();
return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(true).doSkipScenariosAfterFailure(true)).useFailureStrategy(new SilentlyAbsorbingFailure()).useStoryLoader(resourceLoader).useStepPatternParser(new RegexPrefixCapturingPatternParser("MyPrefix")).useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML).withKeywords(new LocalizedKeywords(Locale.ITALIAN)).withRelativeDirectory("my-output-directory").withViewResources(viewResources).withFailureTrace(true)).useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers).addConverters(new CustomConverter(), new MyDateConverter())).useTableTransformers(tableTransformers);
}
Aggregations