Search in sources :

Example 1 with IsDateEqual

use of org.jbehave.core.reporters.StoryNarrator.IsDateEqual in project jbehave-core by jbehave.

the class PrintStreamOutputBehaviour method shouldUseCustomDateFormatInOutcomesTable.

@Test
public void shouldUseCustomDateFormatInOutcomesTable() {
    // Given
    OutputStream out = new ByteArrayOutputStream();
    StoryReporter reporter = new TxtOutput(new PrintStream(out));
    // When
    OutcomesTable outcomesTable = new OutcomesTable(new LocalizedKeywords(), "dd/MM/yyyy");
    Date actualDate = StoryNarrator.dateFor("01/01/2011");
    Date expectedDate = StoryNarrator.dateFor("02/01/2011");
    outcomesTable.addOutcome("A wrong date", actualDate, new IsDateEqual(expectedDate, outcomesTable.getDateFormat()));
    try {
        outcomesTable.verify();
    } catch (UUIDExceptionWrapper e) {
        reporter.failedOutcomes("some step", ((OutcomesFailed) e.getCause()).outcomesTable());
    }
    // Then
    String expected = "some step (FAILED)\n" + "(org.jbehave.core.model.OutcomesTable$OutcomesFailed)\n" + "|Description|Value|Matcher|Verified|\n" + "|A wrong date|01/01/2011|\"02/01/2011\"|No|\n";
    assertThat(dos2unix(out.toString()), equalTo(expected));
}
Also used : OutcomesFailed(org.jbehave.core.model.OutcomesTable.OutcomesFailed) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) OutcomesTable(org.jbehave.core.model.OutcomesTable) Date(java.util.Date) IsDateEqual(org.jbehave.core.reporters.StoryNarrator.IsDateEqual) UUIDExceptionWrapper(org.jbehave.core.failures.UUIDExceptionWrapper) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 UUIDExceptionWrapper (org.jbehave.core.failures.UUIDExceptionWrapper)1 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)1 OutcomesTable (org.jbehave.core.model.OutcomesTable)1 OutcomesFailed (org.jbehave.core.model.OutcomesTable.OutcomesFailed)1 IsDateEqual (org.jbehave.core.reporters.StoryNarrator.IsDateEqual)1 Test (org.junit.Test)1