use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class TestNGCucumberRunner method provideFeatures.
/**
* @return returns the cucumber features as a two dimensional array of
* {@link CucumberFeatureWrapper} objects.
*/
public Object[][] provideFeatures() {
try {
List<CucumberFeature> features = getFeatures();
List<Object[]> featuresList = new ArrayList<Object[]>(features.size());
for (CucumberFeature feature : features) {
featuresList.add(new Object[] { new CucumberFeatureWrapperImpl(feature) });
}
return featuresList.toArray(new Object[][] {});
} catch (CucumberException e) {
return new Object[][] { new Object[] { new CucumberExceptionWrapper(e) } };
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class JavaHookTest method fails_if_hook_argument_is_not_scenario_result.
@Test
public void fails_if_hook_argument_is_not_scenario_result() throws Throwable {
objectFactory.setInstance(new BadHook());
backend.buildWorld();
backend.addHook(BAD_AFTER.getAnnotation(After.class), BAD_AFTER);
HookDefinition bad = glue.getAfterHooks().get(0);
try {
bad.execute(mock(Scenario.class));
fail();
} catch (CucumberException expected) {
assertEquals("When a hook declares an argument it must be of type cucumber.api.Scenario. public void cucumber.runtime.java.JavaHookTest$BadHook.after(java.lang.String)", expected.getMessage());
}
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class DexClassFinder method getDescendants.
@Override
public <T> Collection<Class<? extends T>> getDescendants(final Class<T> parentType, final String packageName) {
final List<Class<? extends T>> result = new ArrayList<Class<? extends T>>();
final Enumeration<String> entries = dexFile.entries();
while (entries.hasMoreElements()) {
final String className = entries.nextElement();
if (isInPackage(className, packageName) && !isGenerated(className)) {
try {
final Class<? extends T> clazz = loadClass(className);
if (clazz != null && !parentType.equals(clazz) && parentType.isAssignableFrom(clazz)) {
result.add(clazz.asSubclass(parentType));
}
} catch (ClassNotFoundException e) {
throw new CucumberException(e);
}
}
}
return result;
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class ConverterWithFormat method transform.
/**
* Parses a value using one of the java.util.text format classes.
*
* @param format The format to use
* @param argument The object to parse
* @return The object
*/
@SuppressWarnings("unchecked")
Object transform(final Format format, final String argument) {
ParsePosition position = new ParsePosition(0);
Object result = format.parseObject(argument, position);
if (position.getErrorIndex() != -1) {
throw new CucumberException("Can't parse '" + argument + "' using format " + format);
}
return result;
}
use of cucumber.runtime.CucumberException in project cucumber-jvm by cucumber.
the class CucumberScenarioOutline method createExampleStep.
static ExampleStep createExampleStep(Step step, ExamplesTableRow header, ExamplesTableRow example) {
Set<Integer> matchedColumns = new HashSet<Integer>();
List<String> headerCells = header.getCells();
List<String> exampleCells = example.getCells();
// Create a step with replaced tokens
String name = replaceTokens(matchedColumns, headerCells, exampleCells, step.getName());
if (name.isEmpty()) {
throw new CucumberException("Step generated from scenario outline '" + step.getName() + "' is empty");
}
return new ExampleStep(step.getComments(), step.getKeyword(), name, step.getLine(), rowsWithTokensReplaced(step.getRows(), headerCells, exampleCells, matchedColumns), docStringWithTokensReplaced(step.getDocString(), headerCells, exampleCells, matchedColumns), matchedColumns);
}
Aggregations