Search in sources :

Example 1 with EmbedderMonitor

use of org.jbehave.core.embedder.EmbedderMonitor 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)

Example 2 with EmbedderMonitor

use of org.jbehave.core.embedder.EmbedderMonitor in project serenity-jbehave by serenity-bdd.

the class CompositeEmbedderMonitor method storiesNotAllowed.

@Override
@Deprecated
public void storiesNotAllowed(final List<Story> notAllowed, final MetaFilter filter) {
    logger.debug("storiesNotAllowed {} {}", notAllowed, filter);
    final LinkedList<Exception> exceptions = new LinkedList<>();
    for (final EmbedderMonitor monitor : this.monitors) {
        try {
            monitor.storiesNotAllowed(notAllowed, filter);
        } catch (final Exception suppressed) {
            logger.error("exception during calling {}#storiesNotAllowed", monitor.getClass(), suppressed);
            exceptions.add(suppressed);
        }
    }
    processSuppressed(exceptions);
}
Also used : EmbedderMonitor(org.jbehave.core.embedder.EmbedderMonitor)

Example 3 with EmbedderMonitor

use of org.jbehave.core.embedder.EmbedderMonitor in project serenity-jbehave by serenity-bdd.

the class CompositeEmbedderMonitor method usingTimeout.

@Override
public void usingTimeout(final String path, final long timeout) {
    logger.debug("usingTimeout {} {}", path, timeout);
    final LinkedList<Exception> exceptions = new LinkedList<>();
    for (final EmbedderMonitor monitor : this.monitors) {
        try {
            monitor.usingTimeout(path, timeout);
        } catch (final Exception suppressed) {
            logger.error("exception during calling {}#usingTimeout", monitor.getClass(), suppressed);
            exceptions.add(suppressed);
        }
    }
    processSuppressed(exceptions);
}
Also used : EmbedderMonitor(org.jbehave.core.embedder.EmbedderMonitor)

Example 4 with EmbedderMonitor

use of org.jbehave.core.embedder.EmbedderMonitor in project serenity-jbehave by serenity-bdd.

the class CompositeEmbedderMonitor method navigatorViewGenerationFailed.

@Override
public void navigatorViewGenerationFailed(final File outputDirectory, final Properties viewResources, final Throwable cause) {
    logger.debug("navigatorViewGenerationFailed {} {} {}", outputDirectory, viewResources, cause);
    final LinkedList<Exception> exceptions = new LinkedList<>();
    for (final EmbedderMonitor monitor : this.monitors) {
        try {
            monitor.navigatorViewGenerationFailed(outputDirectory, viewResources, cause);
        } catch (final Exception suppressed) {
            logger.error("exception during calling {}#navigatorViewGenerationFailed", monitor.getClass(), suppressed);
            exceptions.add(suppressed);
        }
    }
    processSuppressed(exceptions);
}
Also used : EmbedderMonitor(org.jbehave.core.embedder.EmbedderMonitor)

Example 5 with EmbedderMonitor

use of org.jbehave.core.embedder.EmbedderMonitor in project serenity-jbehave by serenity-bdd.

the class CompositeEmbedderMonitor method reportsViewFailures.

@Override
public void reportsViewFailures(final ReportsCount count) {
    logger.debug("reportsViewFailures {}", count);
    final LinkedList<Exception> exceptions = new LinkedList<>();
    for (final EmbedderMonitor monitor : this.monitors) {
        try {
            monitor.reportsViewFailures(count);
        } catch (final Exception suppressed) {
            logger.error("exception during calling {}#reportsViewFailures", monitor.getClass(), suppressed);
            exceptions.add(suppressed);
        }
    }
    processSuppressed(exceptions);
}
Also used : EmbedderMonitor(org.jbehave.core.embedder.EmbedderMonitor)

Aggregations

EmbedderMonitor (org.jbehave.core.embedder.EmbedderMonitor)36 File (java.io.File)2 Properties (java.util.Properties)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)2 Embedder (org.jbehave.core.embedder.Embedder)2 BatchFailures (org.jbehave.core.failures.BatchFailures)2 ReportsCount (org.jbehave.core.reporters.ReportsCount)2 Test (org.junit.Test)2 Log (org.apache.maven.plugin.logging.Log)1 Project (org.apache.tools.ant.Project)1