Search in sources :

Example 1 with EmbedderControls

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();
    }
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) StepFinder(org.jbehave.core.steps.StepFinder) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Embedder(org.jbehave.core.embedder.Embedder) FileNotFoundException(java.io.FileNotFoundException) SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) ByLevenshteinDistance(org.jbehave.core.steps.StepFinder.ByLevenshteinDistance) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) InstanceStepsFactory(org.jbehave.core.steps.InstanceStepsFactory) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) MarkUnmatchedStepsAsPending(org.jbehave.core.steps.MarkUnmatchedStepsAsPending)

Example 2 with EmbedderControls

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));
}
Also used : Embedder(org.jbehave.core.embedder.Embedder) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) Test(org.junit.Test)

Example 3 with EmbedderControls

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();
    }
}
Also used : StoryReporterBuilder(org.jbehave.core.reporters.StoryReporterBuilder) StepFinder(org.jbehave.core.steps.StepFinder) Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) Embedder(org.jbehave.core.embedder.Embedder) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SilentlyAbsorbingFailure(org.jbehave.core.failures.SilentlyAbsorbingFailure) ByLevenshteinDistance(org.jbehave.core.steps.StepFinder.ByLevenshteinDistance) LoadFromClasspath(org.jbehave.core.io.LoadFromClasspath) InstanceStepsFactory(org.jbehave.core.steps.InstanceStepsFactory) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) MarkUnmatchedStepsAsPending(org.jbehave.core.steps.MarkUnmatchedStepsAsPending)

Example 4 with EmbedderControls

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));
}
Also used : Embedder(org.jbehave.core.embedder.Embedder) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) Test(org.junit.Test)

Example 5 with EmbedderControls

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;
}
Also used : UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) UsingEmbedder(org.jbehave.core.annotations.UsingEmbedder) Embedder(org.jbehave.core.embedder.Embedder) ConfigurableEmbedder(org.jbehave.core.ConfigurableEmbedder) EmbedderControls(org.jbehave.core.embedder.EmbedderControls) Properties(java.util.Properties)

Aggregations

EmbedderControls (org.jbehave.core.embedder.EmbedderControls)8 Embedder (org.jbehave.core.embedder.Embedder)7 Test (org.junit.Test)5 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)4 FileNotFoundException (java.io.FileNotFoundException)2 Configuration (org.jbehave.core.configuration.Configuration)2 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)2 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)2 LoadFromClasspath (org.jbehave.core.io.LoadFromClasspath)2 StoryReporterBuilder (org.jbehave.core.reporters.StoryReporterBuilder)2 InstanceStepsFactory (org.jbehave.core.steps.InstanceStepsFactory)2 MarkUnmatchedStepsAsPending (org.jbehave.core.steps.MarkUnmatchedStepsAsPending)2 StepFinder (org.jbehave.core.steps.StepFinder)2 ByLevenshteinDistance (org.jbehave.core.steps.StepFinder.ByLevenshteinDistance)2 IOException (java.io.IOException)1 Properties (java.util.Properties)1 ConfigurableEmbedder (org.jbehave.core.ConfigurableEmbedder)1 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)1