Details
Description
Change the SpringStepsFactory so it doesn't create CandidateSteps but rather return bean instances. That way I can have a different way of instanciating CandidateSteps.
addSteps(new ParameterConverterStepsFactory().createCandidateSteps( new SpringStepsFactory(context).createStepsInstances() ));
And the simplified SpringStepsFactory :
public class SpringStepsFactory { private final ListableBeanFactory parent; public SpringStepsFactory(ListableBeanFactory parent) { this.parent = parent; } public Object[] createStepsInstances() { List<Object> steps = new ArrayList<Object>(); for (String name : parent.getBeanDefinitionNames()) { Object bean = parent.getBean(name); if (containsScenarioAnnotations(bean.getClass())) { steps.add(bean); } } return steps.toArray(new Object[steps.size()]); } private boolean containsScenarioAnnotations(Class<?> componentClass) { for (Method method : componentClass.getMethods()) { for (Annotation annotation : method.getAnnotations()) { if (annotation.annotationType().getName().startsWith("org.jbehave.scenario.annotations")) { return true; } } } return false; } }
Activity
Mauro Talevi
made changes -
Field | Original Value | New Value |
---|---|---|
Status | Open [ 1 ] | Resolved [ 5 ] |
Fix Version/s | 3.0.2 [ 16771 ] | |
Resolution | Fixed [ 1 ] |
We could have both methods in the SpringStepsFactory, one that returns Steps object instances and one that returns CandidateSteps.
Then one could choose which one to use. Would that work?