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));
}
Aggregations