org.jbehave.core.embedder.StoryControls Java Examples

The following examples show how to use org.jbehave.core.embedder.StoryControls. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PortalStories.java    From attic-rave with Apache License 2.0 6 votes vote down vote up
protected PortalStories() {
  CrossReference crossReference = new CrossReference().withJsonOnly().withOutputAfterEachStory(true)
      .excludingStoriesWithNoExecutedScenarios(true);
  ContextView contextView = new LocalFrameContextView().sized(640, 120);
  SeleniumContext seleniumContext = new SeleniumContext();
  SeleniumStepMonitor stepMonitor = new SeleniumStepMonitor(contextView, seleniumContext,
      crossReference.getStepMonitor());
  Format[] formats = new Format[]{new SeleniumContextOutput(seleniumContext), CONSOLE, WEB_DRIVER_HTML};
  StoryReporterBuilder reporterBuilder = new StoryReporterBuilder()
      .withCodeLocation(codeLocationFromClass(this.getClass())).withFailureTrace(true)
      .withFailureTraceCompression(true).withDefaultFormats().withFormats(formats)
      .withCrossReference(crossReference);

  Configuration configuration = new SeleniumConfiguration().useSeleniumContext(seleniumContext)
      .useFailureStrategy(new FailingUponPendingStep())
      .useStoryControls(new StoryControls().doResetStateBeforeScenario(false)).useStepMonitor(stepMonitor)
      .useStoryLoader(new LoadFromClasspath(this.getClass()))
      .useStoryReporterBuilder(reporterBuilder);
  useConfiguration(configuration);

  ApplicationContext context = new SpringApplicationContextFactory("applicationContext-tests.xml").createApplicationContext();
  useStepsFactory(new SpringStepsFactory(configuration, context));
}
 
Example #2
Source File: ExtendedConfigurationTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
@PrepareForTest(ExtendedConfiguration.class)
public void testInit() throws Exception
{
    String compositePathPatterns = "**/*.steps";
    List<String> compositePaths = List.of("/path/to/composite.steps");
    when(pathFinder.findPaths(equalToCompositeStepsBatch(compositePathPatterns))).thenReturn(compositePaths);

    ExtendedConfiguration spy = spy(configuration);
    Keywords keywords = mock(Keywords.class);
    PowerMockito.whenNew(Keywords.class).withArguments(Keywords.defaultKeywords()).thenReturn(keywords);
    ExamplesTableFactory examplesTableFactory = mock(ExamplesTableFactory.class);
    when(spy.examplesTableFactory()).thenReturn(examplesTableFactory);
    RegexStoryParser regexStoryParser = mock(RegexStoryParser.class);
    PowerMockito.whenNew(RegexStoryParser.class).withArguments(keywords, examplesTableFactory)
            .thenReturn(regexStoryParser);
    ParameterConvertersDecorator parameterConverters = mock(ParameterConvertersDecorator.class);
    PowerMockito.whenNew(ParameterConvertersDecorator.class).withArguments(spy, parameterAdaptor, expressionAdaptor)
            .thenReturn(parameterConverters);
    List<ChainableParameterConverter<?, ?>> parameterConverterList = List.of();
    when(parameterConverters.addConverters(parameterConverterList)).thenReturn(parameterConverters);
    StoryControls storyControls = mock(StoryControls.class);
    spy.setCustomConverters(parameterConverterList);
    spy.setCompositePaths(compositePathPatterns);
    spy.setStoryControls(storyControls);
    List<StepMonitor> stepMonitors = List.of(mock(StepMonitor.class));
    spy.setStepMonitors(stepMonitors);
    spy.init();

    verify(spy).useKeywords(keywords);
    verify(spy).useCompositePaths(new HashSet<>(compositePaths));

    InOrder inOrder = inOrder(spy);
    inOrder.verify(spy).useParameterConverters(parameterConverters);
    inOrder.verify(spy).useStoryParser(regexStoryParser);

    verify(spy).useStoryControls(storyControls);
    verifyStepMonitor(spy, stepMonitors.get(0));
}
 
Example #3
Source File: ExtendedConfigurationTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetDryRun() throws IOException
{
    StoryControls storyControls = new StoryControls();
    storyControls.doDryRun(true);
    configuration.setStoryControls(storyControls);
    configuration.init();
    assertTrue(configuration.storyControls().dryRun());
}
 
Example #4
Source File: JBConfiguratorImpl.java    From colibri-ui with Apache License 2.0 5 votes vote down vote up
@Override
public Configuration createConfig() {
    Configuration configuration = new Configuration() {
    };
    configuration.useStoryReporterBuilder(
            new StoryReporterBuilder()
                    .withDefaultFormats()
                    .withFormats(Format.CONSOLE)
                    .withReporters(allureReporter));
    configuration.useStoryControls(new StoryControls().doResetStateBeforeScenario(true));
    configuration.parameterConverters().addConverters(new ParameterConverters.EnumConverter());
    return configuration;
}
 
Example #5
Source File: JBConfiguratorImpl.java    From colibri-ui with Apache License 2.0 5 votes vote down vote up
@Override
public Configuration createConfig(ViewGenerator viewGenerator, Format... formats) {
    Configuration configuration = new MostUsefulConfiguration();
    configuration.useStoryReporterBuilder(
            new StoryReporterBuilder()
                    .withFormats(formats))
            .useViewGenerator(viewGenerator);
    configuration.useStoryControls(new StoryControls().doResetStateBeforeScenario(true));
    configuration.parameterConverters().addConverters(new ParameterConverters.EnumConverter());
    return configuration;
}
 
Example #6
Source File: ExtendedConfiguration.java    From vividus with Apache License 2.0 4 votes vote down vote up
public void setStoryControls(StoryControls storyControls)
{
    this.storyControls = storyControls;
}