use of org.jbehave.core.model.ExamplesTable.RowNotFound in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldThrowExceptionIfValuesOrRowsAreNotFound.
@Test
public void shouldThrowExceptionIfValuesOrRowsAreNotFound() throws Exception {
// Given
ExamplesTableFactory factory = createFactory();
// When
String tableAsString = "|one|two|\n|11|22|\n";
ExamplesTable examplesTable = factory.createExamplesTable(tableAsString);
// Then
Parameters integers = examplesTable.getRowAsParameters(0);
assertThat(integers.<Integer>valueAs("one", Integer.class), equalTo(11));
try {
integers.valueAs("unknown", Integer.class);
throw new AssertionError("Exception was not thrown");
} catch (ValueNotFound e) {
assertThat(e.getMessage(), equalTo("unknown"));
}
try {
examplesTable.getRowAsParameters(1);
throw new AssertionError("Exception was not thrown");
} catch (RowNotFound e) {
assertThat(e.getMessage(), equalTo("1"));
}
}
Aggregations