Search in sources :

Example 1 with ValueNotFound

use of org.jbehave.core.steps.ConvertedParameters.ValueNotFound 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"));
    }
}
Also used : RowNotFound(org.jbehave.core.model.ExamplesTable.RowNotFound) AsParameters(org.jbehave.core.annotations.AsParameters) Parameters(org.jbehave.core.steps.Parameters) ValueNotFound(org.jbehave.core.steps.ConvertedParameters.ValueNotFound) Test(org.junit.Test)

Aggregations

AsParameters (org.jbehave.core.annotations.AsParameters)1 RowNotFound (org.jbehave.core.model.ExamplesTable.RowNotFound)1 ValueNotFound (org.jbehave.core.steps.ConvertedParameters.ValueNotFound)1 Parameters (org.jbehave.core.steps.Parameters)1 Test (org.junit.Test)1