Search in sources :

Example 6 with OutcomesTable

use of org.jbehave.core.model.OutcomesTable in project jbehave-core by jbehave.

the class FrSteps method theResultsMultipliedByAre.

@Then("les valeurs multipliƩes par $multiplier sont: $table")
public void theResultsMultipliedByAre(int multiplier, ExamplesTable results) {
    OutcomesTable outcomes = new OutcomesTable(new LocalizedKeywords(new Locale("fr")));
    for (int row = 0; row < results.getRowCount(); row++) {
        Parameters expected = results.getRowAsParameters(row);
        Parameters original = table.getRowAsParameters(row);
        int one = original.valueAs("un", Integer.class);
        int two = original.valueAs("deux", Integer.class);
        outcomes.addOutcome("un", one * multiplier, Matchers.equalTo(expected.valueAs("un", Integer.class)));
        outcomes.addOutcome("deux", two * multiplier, Matchers.equalTo(expected.valueAs("deux", Integer.class)));
    }
    outcomes.verify();
}
Also used : Locale(java.util.Locale) Parameters(org.jbehave.core.steps.Parameters) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) OutcomesTable(org.jbehave.core.model.OutcomesTable) Then(org.jbehave.core.annotations.Then)

Example 7 with OutcomesTable

use of org.jbehave.core.model.OutcomesTable in project jbehave-core by jbehave.

the class TraderSteps method theTradersReturnedAre.

@Then("the traders returned are: $tradersTable")
public void theTradersReturnedAre(ExamplesTable tradersTable) {
    OutcomesTable outcomes = new OutcomesTable();
    outcomes.addOutcome("traders", searchedTraders.toString(), equalTo(toTraders(tradersTable).toString()));
    outcomes.addOutcome("a success", "Any Value", equalTo("Any Value"));
    outcomes.verify();
}
Also used : OutcomesTable(org.jbehave.core.model.OutcomesTable) Then(org.jbehave.core.annotations.Then)

Example 8 with OutcomesTable

use of org.jbehave.core.model.OutcomesTable 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)

Aggregations

OutcomesTable (org.jbehave.core.model.OutcomesTable)8 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)5 Test (org.junit.Test)4 Then (org.jbehave.core.annotations.Then)3 ExamplesTable (org.jbehave.core.model.ExamplesTable)3 OutcomesFailed (org.jbehave.core.model.OutcomesTable.OutcomesFailed)3 Story (org.jbehave.core.model.Story)3 HashMap (java.util.HashMap)2 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)2 GivenStories (org.jbehave.core.model.GivenStories)2 Scenario (org.jbehave.core.model.Scenario)2 Parameters (org.jbehave.core.steps.Parameters)2 InOrder (org.mockito.InOrder)2 Date (java.util.Date)1 Locale (java.util.Locale)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 PendingStepFound (org.jbehave.core.failures.PendingStepFound)1 Description (org.jbehave.core.model.Description)1 Narrative (org.jbehave.core.model.Narrative)1 IsDateEqual (org.jbehave.core.reporters.StoryNarrator.IsDateEqual)1