use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class PickleStepDefinitionMatch method runStep.
@Override
public void runStep(TestCaseState state) throws Throwable {
List<Argument> arguments = getArguments();
List<ParameterInfo> parameterInfos = stepDefinition.parameterInfos();
if (parameterInfos != null && arguments.size() != parameterInfos.size()) {
throw arityMismatch(parameterInfos.size());
}
List<Object> result = new ArrayList<>();
try {
for (Argument argument : arguments) {
result.add(argument.getValue());
}
} catch (UndefinedDataTableTypeException e) {
throw registerDataTableTypeInConfiguration(e);
} catch (CucumberExpressionException | CucumberDataTableException | CucumberDocStringException e) {
CucumberInvocationTargetException targetException;
if ((targetException = causedByCucumberInvocationTargetException(e)) != null) {
throw removeFrameworkFrames(targetException);
}
throw couldNotConvertArguments(e);
} catch (CucumberBackendException e) {
throw couldNotInvokeArgumentConversion(e);
} catch (CucumberInvocationTargetException e) {
throw removeFrameworkFrames(e);
}
try {
stepDefinition.execute(result.toArray(new Object[0]));
} catch (CucumberBackendException e) {
throw couldNotInvokeStep(e, result);
} catch (CucumberInvocationTargetException e) {
throw removeFrameworkFramesAndAppendStepLocation(e, getStepLocation());
}
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class SpringFactoryTest method shouldFailIfClassWithAnnotationAnnotatedWithSpringComponentAnnotationsIsFound.
@Test
void shouldFailIfClassWithAnnotationAnnotatedWithSpringComponentAnnotationsIsFound() {
final ObjectFactory factory = new SpringFactory();
Executable testMethod = () -> factory.addClass(WithControllerAnnotation.class);
CucumberBackendException actualThrown = assertThrows(CucumberBackendException.class, testMethod);
assertThat(actualThrown.getMessage(), is(equalTo("Glue class io.cucumber.spring.componentannotation.WithControllerAnnotation was annotated with @Controller; marking it as a candidate for auto-detection by Spring. Glue classes are detected and registered by Cucumber. Auto-detection of glue classes by spring may lead to duplicate bean definitions. Please remove the @Controller annotation")));
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class TestContextAdaptor method stop.
public final void stop() {
notifyTestContextManagerAboutAfterTestMethod();
CucumberTestContext.getInstance().stop();
try {
delegate.afterTestClass();
} catch (Exception e) {
throw new CucumberBackendException(e.getMessage(), e);
}
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class TestContextAdaptor method notifyTestContextManagerAboutBeforeTestMethod.
private void notifyTestContextManagerAboutBeforeTestMethod() {
try {
CucumberTestContext.getInstance().start();
Class<?> testClass = delegate.getTestContext().getTestClass();
Object testContextInstance = applicationContext.getBean(testClass);
Method dummyMethod = TestContextAdaptor.class.getMethod("cucumberDoesNotHaveASingleTestMethod");
delegate.beforeTestMethod(testContextInstance, dummyMethod);
} catch (Exception e) {
throw new CucumberBackendException(e.getMessage(), e);
}
}
use of io.cucumber.core.backend.CucumberBackendException in project cucumber-jvm by cucumber.
the class TestContextAdaptor method notifyTestContextManagerAboutAfterTestMethod.
private void notifyTestContextManagerAboutAfterTestMethod() {
try {
CucumberTestContext.getInstance().start();
Class<?> testClass = delegate.getTestContext().getTestClass();
Object testContextInstance = applicationContext.getBean(testClass);
Method dummyMethod = TestContextAdaptor.class.getMethod("cucumberDoesNotHaveASingleTestMethod");
delegate.afterTestMethod(testContextInstance, dummyMethod, null);
} catch (Exception e) {
throw new CucumberBackendException(e.getMessage(), e);
}
}
Aggregations