use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class CoreStoryMaps method configuration.
@Override
public Configuration configuration() {
TableTransformers tableTransformers = new TableTransformers();
ExamplesTableFactory tableFactory = new ExamplesTableFactory(new LoadFromClasspath(this.getClass()), tableTransformers);
return new MostUsefulConfiguration().useStoryParser(new RegexStoryParser(tableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass()))).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class MyStories method configuration.
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withFormats(CONSOLE, TXT, HTML, XML)).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ConfigurationProducer method getConfiguration.
@Produces
@WeldConfiguration
public Configuration getConfiguration() {
LoadFromClasspath resourceLoader = new LoadFromClasspath(getClass().getClassLoader());
TableTransformers tableTransformers = new TableTransformers();
return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(false).doSkipScenariosAfterFailure(false)).useStoryLoader(resourceLoader).useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML)).useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers).addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")))).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class CoreStory method configuration.
@Override
public Configuration configuration() {
Class<? extends Embeddable> embeddableClass = this.getClass();
Properties viewResources = new Properties();
viewResources.put("decorateNonHtml", "true");
LoadFromClasspath resourceLoader = new LoadFromClasspath(embeddableClass);
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
// Start from default ParameterConverters instance
ParameterConverters parameterConverters = new ParameterConverters(resourceLoader, tableTransformers);
// factory to allow parameter conversion and loading from external
// resources (used by StoryParser too)
ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), resourceLoader, parameterConverters, parameterControls, tableTransformers);
// add custom converters
parameterConverters.addConverters(new DateConverter(new SimpleDateFormat("yyyy-MM-dd")), new ExamplesTableConverter(examplesTableFactory));
return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(false).doSkipScenariosAfterFailure(false)).useStoryLoader(resourceLoader).useStoryParser(new RegexStoryParser(examplesTableFactory)).useStoryPathResolver(new UnderscoredCamelCaseResolver()).useStoryReporterBuilder(new StoryReporterBuilder().withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass)).withDefaultFormats().withPathResolver(new ResolveToPackagedName()).withViewResources(viewResources).withFormats(CONSOLE, TXT, HTML_TEMPLATE, XML).withCrossReference(xref).withFailureTrace(true).withFailureTraceCompression(true)).useParameterConverters(parameterConverters).useParameterControls(parameterControls).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithLifecycleAfterUponOutcomeInNonEnglishLocale.
@Test
public void shouldParseStoryWithLifecycleAfterUponOutcomeInNonEnglishLocale() {
String wholeStory = "Lebenszyklus: " + NL + "Nach:" + NL + NL + "Ergebnis: JEDES " + NL + "Gegeben im Lager sind 200 T-Shirts" + NL + "Ergebnis: ERFOLG " + NL + "Gegeben im Lager sind 300 T-Shirts" + NL + "Ergebnis: FEHLER " + NL + "Gegeben im Lager sind 400 T-Shirts" + NL + "Szenario:" + NL + "Wenn ein Kunde 20 T-Shirts bestellt";
parser = new RegexStoryParser(new LocalizedKeywords(Locale.GERMAN), new LoadFromClasspath(), new TableTransformers());
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("Gegeben im Lager sind 200 T-Shirts"));
assertThat(afterSteps.get(1), equalTo("Gegeben im Lager sind 300 T-Shirts"));
assertThat(afterSteps.get(2), equalTo("Gegeben im Lager sind 400 T-Shirts"));
assertThat(lifecycle.getAfterSteps(Outcome.ANY).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.ANY).get(0), equalTo("Gegeben im Lager sind 200 T-Shirts"));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.SUCCESS).get(0), equalTo("Gegeben im Lager sind 300 T-Shirts"));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).size(), equalTo(1));
assertThat(lifecycle.getAfterSteps(Outcome.FAILURE).get(0), equalTo("Gegeben im Lager sind 400 T-Shirts"));
Scenario scenario = story.getScenarios().get(0);
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Wenn ein Kunde 20 T-Shirts bestellt"));
}
Aggregations