use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class SpringStepsFactoryBehaviour method beansWithUndefinedTypeOrCannotBeCreatedWillBeIgnored.
@Test
public void beansWithUndefinedTypeOrCannotBeCreatedWillBeIgnored() {
// Given
ApplicationContext context = mock(ApplicationContext.class);
SpringStepsFactory factory = new SpringStepsFactory(new MostUsefulConfiguration(), context);
// When
when(context.getBeanDefinitionNames()).thenReturn(new String[] { "fooSteps", "undefined", "blowUp" });
doAnswer(new Answer<Class<FooSteps>>() {
public Class<FooSteps> answer(InvocationOnMock invocation) throws Throwable {
return FooSteps.class;
}
}).when(context).getType("fooSteps");
when(context.getType("undefined")).thenReturn(null);
doAnswer(new Answer<Class<BlowUp>>() {
public Class<BlowUp> answer(InvocationOnMock invocation) throws Throwable {
return BlowUp.class;
}
}).when(context).getType("blowUp");
when(context.getBean("fooSteps")).thenReturn(new FooSteps());
when(context.getBean("blowUp")).thenThrow(new RuntimeException("Bum!"));
List<CandidateSteps> candidateSteps = factory.createCandidateSteps();
// Then
assertThat(candidateSteps.size(), equalTo(1));
assertThat(firstStepsInstance(candidateSteps), instanceOf(FooSteps.class));
verify(context, never()).getBean("undefined");
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class ConfigurationProducer method getConfiguration.
@Produces
@WeldConfiguration
Configuration getConfiguration() {
Properties viewResources = new Properties();
viewResources.setProperty("index", "my-reports-index.ftl");
viewResources.setProperty("decorateNonHtml", "true");
TableTransformers tableTransformers = new TableTransformers();
LoadFromURL resourceLoader = new LoadFromURL();
return new MostUsefulConfiguration().useStoryControls(new StoryControls().doDryRun(true).doSkipScenariosAfterFailure(true)).useFailureStrategy(new SilentlyAbsorbingFailure()).useStoryLoader(resourceLoader).useStepPatternParser(new RegexPrefixCapturingPatternParser("MyPrefix")).useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(CONSOLE, HTML, TXT, XML).withKeywords(new LocalizedKeywords(Locale.ITALIAN)).withRelativeDirectory("my-output-directory").withViewResources(viewResources).withFailureTrace(true)).useParameterConverters(new ParameterConverters(resourceLoader, tableTransformers).addConverters(new CustomConverter(), new MyDateConverter())).useTableTransformers(tableTransformers);
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class PicoStepsFactoryBehaviour method assertThatStepsCanBeCreated.
@Test
public void assertThatStepsCanBeCreated() throws NoSuchFieldException, IllegalAccessException {
// Given
MutablePicoContainer parent = createPicoContainer();
parent.as(Characteristics.USE_NAMES).addComponent(FooSteps.class);
PicoStepsFactory factory = new PicoStepsFactory(new MostUsefulConfiguration(), parent);
// When
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertFooStepsFound(steps);
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class NeedleStepsFactoryBehaviour method stepsShouldContainInjectedDependencies.
@Test
public void stepsShouldContainInjectedDependencies() throws NoSuchFieldException, IllegalAccessException {
// Given
final InjectableStepsFactory factory = new NeedleStepsFactory(new MostUsefulConfiguration(), FooStepsWithDependency.class);
// When
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertThat(steps.size(), equalTo(1));
boolean actual1 = steps.get(0) instanceof CandidateSteps;
assertThat(actual1, is(true));
Object instance = stepsInstance(steps.get(0));
boolean actual = instance instanceof FooStepsWithDependency;
assertThat(actual, is(true));
FooStepsWithDependency withDependency = (FooStepsWithDependency) instance;
assertThat(withDependency.getter, is(notNullValue()));
assertThat((String) withDependency.getter.getValue(), equalTo(ValueGetter.VALUE));
}
use of org.jbehave.core.configuration.MostUsefulConfiguration in project jbehave-core by jbehave.
the class NeedleStepsFactoryBehaviour method stepsShouldBeCreated.
@Test
public void stepsShouldBeCreated() throws NoSuchFieldException, IllegalAccessException {
// Given
final InjectableStepsFactory factory = new NeedleStepsFactory(new MostUsefulConfiguration(), FooSteps.class);
// When
List<CandidateSteps> steps = factory.createCandidateSteps();
// Then
assertThat(steps.size(), equalTo(1));
boolean actual1 = steps.get(0) instanceof CandidateSteps;
assertThat(actual1, is(true));
Object instance = stepsInstance(steps.get(0));
boolean actual = instance instanceof FooSteps;
assertThat(actual, is(true));
}
Aggregations