private void useDefaultStepFactoryIfUnassigned() { if (factory == null) { factory = getDefaultStepFactory(); } }
@SuppressWarnings("unchecked") public <T> T run(final T steps) throws IOException { useDefaultStepFactoryIfUnassigned(); StepEventBus.getEventBus().useExamplesFrom(dataTable(testdata)); Class<?> scenarioStepsClass = steps.getClass().getSuperclass(); List<T> instanciatedSteps = (List<T>) testdata.getInstanciatedInstancesFrom(scenarioStepsClass, factory); DataDrivenStepFactory dataDrivenStepFactory = new DataDrivenStepFactory(factory); T stepsProxy = (T) dataDrivenStepFactory.newDataDrivenSteps(scenarioStepsClass, instanciatedSteps); return stepsProxy; }
@Then("^the values should be correct$") public void thenTheValuesShouldBeCorrect() throws IOException { withTestDataFrom(dataSource).run(checkValueSteps).checkValues(); }
public static StepData withTestDataFrom(final String testDataSource) throws IOException { return new StepData(new CSVTestDataSource(testDataSource, DEFAULT_SEPARATOR)); }
private DataTable dataTable(TestDataSource testdata) { return DataTable.withHeaders(testdata.getHeaders()) .andRows(rowsFrom(testdata)).build(); }
public static StepData withTestDataFrom(final String... testDataRows) throws IOException { return new StepData(new StringTestDataSource(testDataRows)); }