Search in sources :

Example 31 with StoryReporter

use of org.jbehave.core.reporters.StoryReporter in project jbehave-core by jbehave.

the class StepResultBehaviour method shouldDescribeResultToReporter.

@Test
public void shouldDescribeResultToReporter() {
    // Given
    StoryReporter reporter = mock(StoryReporter.class);
    // When
    String successful = "Given that a step is pending or failing";
    successful(successful).describeTo(reporter);
    String pending = "When a step is performed";
    pending(pending).describeTo(reporter);
    PendingStepFound pendingStepFound = new PendingStepFound(pending);
    pending(pending, pendingStepFound).describeTo(reporter);
    String notPerformed = "Then the step should describe itself properly to reporters";
    notPerformed(notPerformed).describeTo(reporter);
    String ignorable = "!-- Then ignore me";
    ignorable(ignorable).describeTo(reporter);
    String comment = "!-- this is a comment";
    comment(comment).describeTo(reporter);
    String failed = "And any errors should appear at the end of the story";
    UUIDExceptionWrapper cause = new UUIDExceptionWrapper(new IllegalStateException());
    failed(failed, cause).describeTo(reporter);
    String failedOutcomes = "And outcomes failed";
    OutcomesTable outcomesTable = new OutcomesTable();
    failed(failedOutcomes, new UUIDExceptionWrapper(new OutcomesFailed(outcomesTable))).describeTo(reporter);
    skipped().describeTo(reporter);
    // Then
    verify(reporter).successful(successful);
    verify(reporter, times(2)).pending(pending);
    verify(reporter).notPerformed(notPerformed);
    verify(reporter).ignorable(ignorable);
    verify(reporter).comment(comment);
    verify(reporter).failed(failed, cause);
    verify(reporter).failedOutcomes(failedOutcomes, outcomesTable);
}
Also used : StoryReporter(org.jbehave.core.reporters.StoryReporter) OutcomesFailed(org.jbehave.core.model.OutcomesTable.OutcomesFailed) PendingStepFound(org.jbehave.core.failures.PendingStepFound) Matchers.containsString(org.hamcrest.Matchers.containsString) OutcomesTable(org.jbehave.core.model.OutcomesTable) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper) Test(org.junit.Test)

Example 32 with StoryReporter

use of org.jbehave.core.reporters.StoryReporter in project jbehave-core by jbehave.

the class StepCandidateBehaviour method shouldCreateStepFromTableValuesViaAnnotationsWithCustomParameterDelimiters.

@Test
public void shouldCreateStepFromTableValuesViaAnnotationsWithCustomParameterDelimiters() throws Exception {
    StoryReporter reporter = mock(StoryReporter.class);
    AnnotationNamedParameterSteps steps = new AnnotationNamedParameterSteps();
    namedParameters.put("ith", "first");
    namedParameters.put("nth", "ground");
    String patternAsString = "I live on the ith floor but some call it the nth";
    Method method = stepMethodFor("methodWithNamedParametersInNaturalOrder", AnnotationNamedParameterSteps.class);
    StepCandidate candidate = candidateWith(patternAsString, WHEN, method, steps, new ParameterControls().useNameDelimiterLeft("[").useNameDelimiterRight("]"));
    StepResult result = candidate.createMatchedStep("When I live on the [ith] floor but some call it the [nth]", namedParameters).perform(null);
    assertThat(steps.ith, equalTo("first"));
    assertThat(steps.nth, equalTo("ground"));
    result.describeTo(reporter);
    verify(reporter).successful("When I live on the " + PARAMETER_VALUE_START + "first" + PARAMETER_VALUE_END + " floor but some call it the " + PARAMETER_VALUE_START + "ground" + PARAMETER_VALUE_END);
}
Also used : StoryReporter(org.jbehave.core.reporters.StoryReporter) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

StoryReporter (org.jbehave.core.reporters.StoryReporter)32 Test (org.junit.Test)32 ConcurrentStoryReporter (org.jbehave.core.reporters.ConcurrentStoryReporter)24 AbstractStep (org.jbehave.core.steps.StepCreator.AbstractStep)19 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)16 Configuration (org.jbehave.core.configuration.Configuration)15 AbstractStepResult (org.jbehave.core.steps.AbstractStepResult)10 InOrder (org.mockito.InOrder)8 Method (java.lang.reflect.Method)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 OutputStream (java.io.OutputStream)2 PrintStream (java.io.PrintStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)2 UsingEmbedder (org.jbehave.core.annotations.UsingEmbedder)2 RunContext (org.jbehave.core.embedder.PerformableTree.RunContext)2 BatchFailures (org.jbehave.core.failures.BatchFailures)2 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)2