Search in sources :

Example 16 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class JUnitStories method run.

@Test
public void run() throws Throwable {
    Embedder embedder = configuredEmbedder();
    try {
        embedder.runStoriesAsPaths(storyPaths());
    } finally {
        embedder.generateCrossReference();
        embedder.generateSurefireReport();
    }
}
Also used : ConfigurableEmbedder(org.jbehave.core.ConfigurableEmbedder) Embedder(org.jbehave.core.embedder.Embedder) Test(org.junit.Test)

Example 17 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class JUnitStory method run.

@Test
public void run() throws Throwable {
    Embedder embedder = configuredEmbedder();
    StoryPathResolver pathResolver = embedder.configuration().storyPathResolver();
    String storyPath = pathResolver.resolve(this.getClass());
    try {
        embedder.runStoriesAsPaths(asList(storyPath));
    } finally {
        embedder.generateCrossReference();
        embedder.generateSurefireReport();
    }
}
Also used : StoryPathResolver(org.jbehave.core.io.StoryPathResolver) ConfigurableEmbedder(org.jbehave.core.ConfigurableEmbedder) Embedder(org.jbehave.core.embedder.Embedder) Test(org.junit.Test)

Example 18 with Embedder

use of org.jbehave.core.embedder.Embedder 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 19 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class EmbedderTaskBehaviour method shouldAllowSpecificationOfEmbedderClass.

@Test
public void shouldAllowSpecificationOfEmbedderClass() {
    // Given
    AbstractEmbedderTask task = new AbstractEmbedderTask() {
    };
    // When
    task.setEmbedderClass(MyEmbedder.class.getName());
    Embedder embedder = task.newEmbedder();
    // Then
    assertThat(embedder.getClass().getName(), equalTo(MyEmbedder.class.getName()));
}
Also used : Embedder(org.jbehave.core.embedder.Embedder) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) Test(org.junit.Test)

Example 20 with Embedder

use of org.jbehave.core.embedder.Embedder in project jbehave-core by jbehave.

the class EmbedderTaskBehaviour method shouldCreateNewEmbedderWithAntMonitor.

@Test
public void shouldCreateNewEmbedderWithAntMonitor() {
    // Given
    Project project = mock(Project.class);
    AbstractEmbedderTask task = new AbstractEmbedderTask() {
    };
    task.setProject(project);
    // When
    Embedder embedder = task.newEmbedder();
    // Then
    EmbedderMonitor embedderMonitor = embedder.embedderMonitor();
    assertThat(embedderMonitor.toString(), equalTo("AntEmbedderMonitor"));
    // and verify monitor calls are propagated to Project log
    BatchFailures failures = new BatchFailures();
    embedderMonitor.batchFailed(failures);
    verify(project).log(task, "Failed to run batch " + failures, MSG_WARN);
    String name = "name";
    Throwable cause = new RuntimeException();
    embedderMonitor.embeddableFailed(name, cause);
    verify(project).log(task, "Failed to run embeddable " + name, cause, MSG_WARN);
    List<String> classNames = asList("name1", "name2");
    embedderMonitor.embeddablesSkipped(classNames);
    verify(project).log(task, "Skipped embeddables " + classNames, MSG_INFO);
    embedderMonitor.runningEmbeddable(name);
    verify(project).log(task, "Running embeddable " + name, MSG_INFO);
    List<String> storyPaths = asList("/path1", "/path2");
    embedderMonitor.storiesSkipped(storyPaths);
    verify(project).log(task, "Skipped stories " + storyPaths, MSG_INFO);
    String path = "/path";
    embedderMonitor.storyFailed(path, cause);
    verify(project).log(task, "Failed to run story " + path, cause, MSG_WARN);
    embedderMonitor.runningStory(path);
    verify(project).log(task, "Running story " + path, MSG_INFO);
    Object annotatedInstance = new Object();
    Class<?> type = Object.class;
    embedderMonitor.annotatedInstanceNotOfType(annotatedInstance, type);
    verify(project).log(task, "Annotated instance " + annotatedInstance + " not of type " + type, MSG_WARN);
    File outputDirectory = new File("/dir");
    List<String> formats = asList(Format.CONSOLE.name(), Format.HTML.name());
    Properties viewProperties = new Properties();
    embedderMonitor.generatingReportsView(outputDirectory, formats, viewProperties);
    verify(project).log(task, "Generating reports view to '" + outputDirectory + "' using formats '" + formats + "'" + " and view properties '" + viewProperties + "'", MSG_INFO);
    embedderMonitor.reportsViewGenerationFailed(outputDirectory, formats, viewProperties, cause);
    verify(project).log(task, "Failed to generate reports view to '" + outputDirectory + "' using formats '" + formats + "'" + " and view properties '" + viewProperties + "'", cause, MSG_WARN);
    int stories = 2;
    int storiesNotAllowed = 1;
    int storiesPending = 1;
    int scenarios = 4;
    int scenariosFailed = 1;
    int scenariosNotAllowed = 0;
    int scenariosPending = 1;
    int stepsFailed = 1;
    embedderMonitor.reportsViewGenerated(new ReportsCount(stories, storiesNotAllowed, storiesPending, scenarios, scenariosFailed, scenariosNotAllowed, scenariosPending, stepsFailed));
    verify(project).log(task, "Reports view generated with " + stories + " stories (of which " + storiesPending + " pending) containing " + scenarios + " scenarios (of which " + scenariosPending + " pending)", MSG_INFO);
    verify(project).log(task, "Meta filters excluded " + storiesNotAllowed + " stories and  " + scenariosNotAllowed + " scenarios", MSG_INFO);
    embedderMonitor.reportsViewNotGenerated();
    verify(project).log(task, "Reports view not generated", MSG_INFO);
}
Also used : EmbedderMonitor(org.jbehave.core.embedder.EmbedderMonitor) Embedder(org.jbehave.core.embedder.Embedder) InjectableEmbedder(org.jbehave.core.InjectableEmbedder) Matchers.containsString(org.hamcrest.Matchers.containsString) Properties(java.util.Properties) Project(org.apache.tools.ant.Project) BatchFailures(org.jbehave.core.failures.BatchFailures) ReportsCount(org.jbehave.core.reporters.ReportsCount) File(java.io.File) Test(org.junit.Test)

Aggregations

Embedder (org.jbehave.core.embedder.Embedder)56 Test (org.junit.Test)33 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)25 ConfigurableEmbedder (org.jbehave.core.ConfigurableEmbedder)10 MojoFailureException (org.apache.maven.plugin.MojoFailureException)8 EmbedderControls (org.jbehave.core.embedder.EmbedderControls)7 Configuration (org.jbehave.core.configuration.Configuration)6 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)6 File (java.io.File)5 Properties (java.util.Properties)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)5 CandidateSteps (org.jbehave.core.steps.CandidateSteps)5 StoryPathResolver (org.jbehave.core.io.StoryPathResolver)4 HashSet (java.util.HashSet)3 Artifact (org.apache.maven.artifact.Artifact)3 Build (org.apache.maven.model.Build)3 MavenProject (org.apache.maven.project.MavenProject)3 ArchiverManager (org.codehaus.plexus.archiver.manager.ArchiverManager)3 StoryFinder (org.jbehave.core.io.StoryFinder)3