use of org.jbehave.core.embedder.EmbedderControls in project jbehave-core by jbehave.
the class ReportTransformBehaviour method runStories.
private void runStories(String... storyPaths) {
StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder().withDefaultFormats().withCodeLocation(CodeLocations.codeLocationFromClass(ReportTransformBehaviour.class)).withFormats(Format.XML);
Configuration configuration = new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass())).useStoryReporterBuilder(storyReporterBuilder).useFailureStrategy(new SilentlyAbsorbingFailure()).useStepCollector(new MarkUnmatchedStepsAsPending(new StepFinder(new ByLevenshteinDistance())));
Embedder embedder = new Embedder();
embedder.useEmbedderControls(new EmbedderControls().doGenerateViewAfterStories(false));
embedder.useConfiguration(configuration);
embedder.useCandidateSteps(new InstanceStepsFactory(configuration, new MySteps()).createCandidateSteps());
embedder.useMetaFilters(asList("-skip true"));
try {
embedder.runStoriesAsPaths(asList(storyPaths));
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.jbehave.core.embedder.EmbedderControls in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldCreateNewEmbedderWithDefaultControls.
@Test
public void shouldCreateNewEmbedderWithDefaultControls() {
// Given
AbstractEmbedderMojo mojo = new AbstractEmbedderMojo() {
public void execute() throws MojoExecutionException, MojoFailureException {
}
};
// When
Embedder embedder = mojo.newEmbedder();
// Then
EmbedderControls embedderControls = embedder.embedderControls();
assertThat(embedderControls.batch(), is(false));
assertThat(embedderControls.generateViewAfterStories(), is(true));
assertThat(embedderControls.ignoreFailureInStories(), is(false));
assertThat(embedderControls.ignoreFailureInView(), is(false));
assertThat(embedderControls.threads(), is(1));
assertThat(embedderControls.skip(), is(false));
assertThat(embedderControls.storyTimeouts(), equalTo("300"));
assertThat(embedderControls.failOnStoryTimeout(), is(false));
assertThat(embedderControls.threads(), equalTo(1));
}
use of org.jbehave.core.embedder.EmbedderControls in project jbehave-core by jbehave.
the class ReportTransformBehaviour method runStories.
private void runStories(String... storyPaths) {
StoryReporterBuilder storyReporterBuilder = new StoryReporterBuilder().withDefaultFormats().withCodeLocation(CodeLocations.codeLocationFromClass(ReportTransformBehaviour.class)).withFormats(Format.XML);
Configuration configuration = new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass())).useStoryReporterBuilder(storyReporterBuilder).useFailureStrategy(new SilentlyAbsorbingFailure()).useStepCollector(new MarkUnmatchedStepsAsPending(new StepFinder(new ByLevenshteinDistance())));
Embedder embedder = new Embedder();
embedder.useEmbedderControls(new EmbedderControls().doGenerateViewAfterStories(false));
embedder.useConfiguration(configuration);
embedder.useCandidateSteps(new InstanceStepsFactory(configuration, new MySteps()).createCandidateSteps());
embedder.useMetaFilters(asList("-skip true"));
try {
embedder.runStoriesAsPaths(asList(storyPaths));
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.jbehave.core.embedder.EmbedderControls in project jbehave-core by jbehave.
the class EmbedderTaskBehaviour method shouldCreateNewEmbedderWithDefaultControls.
@Test
public void shouldCreateNewEmbedderWithDefaultControls() {
// Given
AbstractEmbedderTask task = new AbstractEmbedderTask() {
};
// When
Embedder embedder = task.newEmbedder();
// Then
EmbedderControls embedderControls = embedder.embedderControls();
assertThat(embedderControls.batch(), is(false));
assertThat(embedderControls.generateViewAfterStories(), is(true));
assertThat(embedderControls.ignoreFailureInStories(), is(false));
assertThat(embedderControls.ignoreFailureInView(), is(false));
assertThat(embedderControls.verboseFailures(), is(false));
assertThat(embedderControls.verboseFiltering(), is(false));
assertThat(embedderControls.skip(), is(false));
assertThat(embedderControls.storyTimeouts(), equalTo("300"));
assertThat(embedderControls.failOnStoryTimeout(), is(false));
assertThat(embedderControls.threads(), equalTo(1));
}
use of org.jbehave.core.embedder.EmbedderControls in project jbehave-core by jbehave.
the class AnnotationBuilder method buildEmbedder.
public Embedder buildEmbedder() {
if (!finder.isAnnotationPresent(UsingEmbedder.class)) {
return defaultEmbedder();
}
boolean batch = control(finder, "batch");
boolean skip = control(finder, "skip");
boolean generateViewAfterStories = control(finder, "generateViewAfterStories");
boolean ignoreFailureInStories = control(finder, "ignoreFailureInStories");
boolean ignoreFailureInView = control(finder, "ignoreFailureInView");
boolean verboseFailures = control(finder, "verboseFailures");
boolean verboseFiltering = control(finder, "verboseFiltering");
String storyTimeouts = finder.getAnnotatedValue(UsingEmbedder.class, String.class, "storyTimeouts");
long storyTimeoutInSecs = finder.getAnnotatedValue(UsingEmbedder.class, Long.class, "storyTimeoutInSecs");
String storyTimeoutInSecsByPath = finder.getAnnotatedValue(UsingEmbedder.class, String.class, "storyTimeoutInSecsByPath");
boolean failOnStoryTimeout = control(finder, "failOnStoryTimeout");
int threads = finder.getAnnotatedValue(UsingEmbedder.class, Integer.class, "threads");
Embedder embedder = embedder();
EmbedderControls embedderControls = embedder.embedderControls();
embedderControls.doBatch(batch).doSkip(skip).doGenerateViewAfterStories(generateViewAfterStories).doIgnoreFailureInStories(ignoreFailureInStories).doIgnoreFailureInView(ignoreFailureInView).doVerboseFailures(verboseFailures).doVerboseFiltering(verboseFiltering).doFailOnStoryTimeout(failOnStoryTimeout).useThreads(threads);
if (storyTimeoutInSecs != 0) {
embedderControls.useStoryTimeoutInSecs(storyTimeoutInSecs);
}
if (StringUtils.isNotBlank(storyTimeoutInSecsByPath)) {
embedderControls.useStoryTimeoutInSecsByPath(storyTimeoutInSecsByPath);
}
if (StringUtils.isNotBlank(storyTimeouts)) {
embedderControls.useStoryTimeouts(storyTimeouts);
}
Configuration configuration = buildConfiguration();
embedder.useConfiguration(configuration);
boolean useStepsFactory = finder.getAnnotatedValue(UsingEmbedder.class, Boolean.class, "stepsFactory");
if (useStepsFactory) {
embedder.useStepsFactory(buildStepsFactory(configuration));
} else {
embedder.useCandidateSteps(buildCandidateSteps(configuration));
}
List<String> metaFilters = finder.getAnnotatedValues(UsingEmbedder.class, String.class, "metaFilters");
if (!metaFilters.isEmpty()) {
embedder.useMetaFilters(metaFilters);
}
Properties systemProperties = loadProperties(finder.getAnnotatedValue(UsingEmbedder.class, String.class, "systemProperties"));
if (!systemProperties.isEmpty()) {
embedder.useSystemProperties(systemProperties);
}
return embedder;
}
Aggregations