org.jbehave.core.embedder.EmbedderControls Java Examples

The following examples show how to use org.jbehave.core.embedder.EmbedderControls. 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: BatchedEmbedderTests.java    From vividus with Apache License 2.0 6 votes vote down vote up
@Test
void testRunStoriesAsPaths()
{
    BatchedEmbedder spy = createBatchedEmbedderSpy(true);
    doNothing().when(spy).generateReportsView();
    MetaFilter mockedFilter = mock(MetaFilter.class);
    doReturn(mockedFilter).when(spy).metaFilter();
    List<String> testStoryPaths = List.of(PATH);
    EmbedderControls mockedEmbedderControls = mockEmbedderControls(spy);
    when(mockedEmbedderControls.threads()).thenReturn(THREADS);
    mockBatchExecutionConfiguration(true);
    spy.runStoriesAsPaths(Map.of(BATCH, testStoryPaths));
    InOrder ordered = inOrder(spy, embedderMonitor, storyManager, bddRunContext, bddVariableContext);
    ordered.verify(spy).processSystemProperties();
    ordered.verify(embedderMonitor).usingControls(mockedEmbedderControls);
    List<ExecutorService> service = new ArrayList<>(1);
    ordered.verify(spy).useExecutorService(argThat(service::add));
    ordered.verify(bddRunContext).putRunningBatch(BATCH);
    ordered.verify(storyManager).runStoriesAsPaths(eq(testStoryPaths), eq(mockedFilter), any(BatchFailures.class));
    ordered.verify(bddVariableContext).clearVariables();
    ordered.verify(bddRunContext).removeRunningBatch();
    ordered.verify(spy).generateReportsView();
    ordered.verifyNoMoreInteractions();
    verifyExecutorService(service.get(0));
}
 
Example #2
Source File: AllureJbehaveTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private AllureResults runStories(final String... storyResources) {
    final AllureResultsWriterStub writer = new AllureResultsWriterStub();
    final AllureLifecycle lifecycle = new AllureLifecycle(writer);

    final Embedder embedder = new Embedder();
    embedder.useEmbedderMonitor(new NullEmbedderMonitor());
    embedder.useEmbedderControls(new EmbedderControls()
            .doGenerateViewAfterStories(false)
            .doFailOnStoryTimeout(false)
            .doBatch(false)
            .doIgnoreFailureInStories(true)
            .doIgnoreFailureInView(true)
            .doVerboseFailures(false)
            .doVerboseFiltering(false)
    );
    final AllureJbehave allureJbehave = new AllureJbehave(lifecycle);
    embedder.useConfiguration(new MostUsefulConfiguration()
            .useStoryLoader(new LoadFromClasspath(this.getClass()))
            .useStoryReporterBuilder(new ReportlessStoryReporterBuilder(temp.toFile())
                    .withReporters(allureJbehave)
            )
            .useDefaultStoryReporter(new NullStoryReporter())
    );
    final InjectableStepsFactory stepsFactory = new InstanceStepsFactory(
            embedder.configuration(),
            new SimpleStorySteps(),
            new BrokenStorySteps()
    );
    embedder.useCandidateSteps(stepsFactory.createCandidateSteps());
    final AllureLifecycle cached = Allure.getLifecycle();
    try {
        Allure.setLifecycle(lifecycle);
        embedder.runStoriesAsPaths(Arrays.asList(storyResources));
    } finally {
        Allure.setLifecycle(cached);
    }
    return writer;
}
 
Example #3
Source File: BatchedEmbedder.java    From vividus with Apache License 2.0 5 votes vote down vote up
private EmbedderControls createEmbedderControls(BatchExecutionConfiguration batchExecutionConfiguration)
{
    EmbedderControls embedderControls = new EmbedderControls();
    embedderControls.useStoryTimeouts(
            Long.toString(batchExecutionConfiguration.getStoryExecutionTimeout().toSeconds()));
    Optional.ofNullable(batchExecutionConfiguration.getThreads())
            .ifPresent(embedderControls::useThreads);
    embedderControls.doIgnoreFailureInStories(true);
    embedderControls.doGenerateViewAfterStories(false);
    return embedderControls;
}
 
Example #4
Source File: BatchedEmbedderTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void testRunStoriesAsPathsSkip()
{
    BatchedEmbedder spy = createBatchedEmbedderSpy(false);
    EmbedderControls mockedEmbedderControls = mockEmbedderControls(spy);
    when(mockedEmbedderControls.threads()).thenReturn(THREADS);
    when(mockedEmbedderControls.skip()).thenReturn(true);
    List<String> testStoryPaths = List.of(PATH);
    mockBatchExecutionConfiguration(true);
    spy.runStoriesAsPaths(Map.of(BATCH, testStoryPaths));
    verify(spy).processSystemProperties();
    verify(embedderMonitor).usingControls(mockedEmbedderControls);
    verify(embedderMonitor).storiesSkipped(testStoryPaths);
}
 
Example #5
Source File: BatchedEmbedderTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void testStoryManager()
{
    ExtendedConfiguration mockedConfiguration = mock(ExtendedConfiguration.class);
    ExtendedStoryReporterBuilder mockedExtendedStoryReporterBuilder = mock(ExtendedStoryReporterBuilder.class);
    when(mockedConfiguration.storyReporterBuilder()).thenReturn(mockedExtendedStoryReporterBuilder);
    BatchedEmbedder embedder = new BatchedEmbedder(bddRunContext, bddVariableContext, batchStorage);
    embedder.setEmbedderMonitor(embedderMonitor);
    BatchedEmbedder spy = spy(embedder);
    spy.useConfiguration(mockedConfiguration);
    InjectableStepsFactory mockedInjectableStepsFactory = mock(InjectableStepsFactory.class);
    spy.useStepsFactory(mockedInjectableStepsFactory);
    EmbedderControls mockedEmbedderControls = mockEmbedderControls(spy);
    when(mockedEmbedderControls.threads()).thenReturn(THREADS);
    ExecutorService mockedExecutorService = mock(ExecutorService.class);
    spy.useExecutorService(mockedExecutorService);
    PerformableTree mockedPerformableTree = mock(BatchedPerformableTree.class);
    PerformableTree.PerformableRoot mockedPerformableRoot = mock(PerformableTree.PerformableRoot.class);
    when(mockedPerformableTree.getRoot()).thenReturn(mockedPerformableRoot);
    spy.usePerformableTree(mockedPerformableTree);
    TimeoutParser mockedTimeoutParser = mock(TimeoutParser.class);
    TimeoutParser[] timeoutParsers = { mockedTimeoutParser };
    spy.useTimeoutParsers(timeoutParsers);
    StoryManager expected = new StoryManager(mockedConfiguration, mockedInjectableStepsFactory,
            mockedEmbedderControls, embedderMonitor, mockedExecutorService, mockedPerformableTree, timeoutParsers);
    StoryManager actual = spy.storyManager();
    assertEquals(expected.performableRoot(), actual.performableRoot());
}
 
Example #6
Source File: BatchedEmbedderTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
private boolean assertEmbedderControls(EmbedderControls controls)
{
    return controls.threads() == THREADS
            && "3600".equals(controls.storyTimeouts())
            && controls.ignoreFailureInStories()
            && !controls.generateViewAfterStories();
}
 
Example #7
Source File: JBConfiguratorImpl.java    From colibri-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(EmbedderControls embedderControls, DriversSettings driversSettings) {
    embedderControls.doBatch(false);
    embedderControls.doGenerateViewAfterStories(true);
    embedderControls.doIgnoreFailureInStories(false);
    embedderControls.doIgnoreFailureInView(false);
    embedderControls.doSkip(false);
    embedderControls.doVerboseFailures(false);
    embedderControls.doVerboseFiltering(false);
    embedderControls.useStoryTimeouts(driversSettings.getStoryTimeoutsInSeconds());
    embedderControls.useThreads(1);
}
 
Example #8
Source File: AbstractSpringJBehaveStory.java    From angularjs-springmvc-sample-boot with Apache License 2.0 5 votes vote down vote up
private EmbedderControls embedderControls() {
    return new EmbedderControls()
            .doIgnoreFailureInView(false)
            .doIgnoreFailureInStories(false)
            .doVerboseFailures(true)
            .doVerboseFiltering(true)
            .useStoryTimeouts(STORY_TIMEOUT_IN_SECONDS);
}
 
Example #9
Source File: BatchedEmbedder.java    From vividus with Apache License 2.0 4 votes vote down vote up
public void runStoriesAsPaths(Map<String, List<String>> storyPathsBatches)
{
    processSystemProperties();
    int batchesSize = storyPathsBatches.size();
    Iterator<Entry<String, List<String>>> iterator = storyPathsBatches.entrySet().iterator();
    generateViewAfterExecution(() ->
    {
        for (int i = 1; iterator.hasNext(); i++)
        {
            reportBeforeStories = i == 1;
            reportAfterStories = i == batchesSize;

            Entry<String, List<String>> storyPathsBatch = iterator.next();
            batch = storyPathsBatch.getKey();

            BatchExecutionConfiguration batchExecutionConfiguration = batchStorage.getBatchExecutionConfiguration(
                    batch);
            useEmbedderControls(createEmbedderControls(batchExecutionConfiguration));
            useMetaFilters(batchExecutionConfiguration.getMetaFilters());

            ignoreFailure = batchExecutionConfiguration.isIgnoreFailure();

            EmbedderControls embedderControls = embedderControls();
            embedderMonitor.usingControls(embedderControls);
            ExecutorService executorService = createExecutorService(embedderControls.threads());
            useExecutorService(executorService);

            List<String> storyPaths = storyPathsBatch.getValue();
            if (embedderControls.skip())
            {
                embedderMonitor.storiesSkipped(storyPaths);
                continue;
            }

            try
            {
                bddRunContext.putRunningBatch(batch);

                // JBehaveJUnitRunner may have already initialized StoryManager with default PerformableTree and
                // EmebedderControls, so we need to reset it and new one will be created in storyManager()
                storyManager = null;

                MetaFilter filter = metaFilter();
                BatchFailures failures = new BatchFailures(embedderControls.verboseFailures());

                storyManager().runStoriesAsPaths(storyPaths, filter, failures);

                handleFailures(failures);
                if (!ignoreFailure && !failures.isEmpty())
                {
                    break;
                }
            }
            finally
            {
                bddVariableContext.clearVariables();
                bddRunContext.removeRunningBatch();
                executorService.shutdownNow();
                storyManager = null;
            }
        }
    });
}
 
Example #10
Source File: LoggingEmbedderMonitor.java    From vividus with Apache License 2.0 4 votes vote down vote up
@Override
public void usingControls(EmbedderControls embedderControls)
{
    // Nothing to doF
}
 
Example #11
Source File: BatchedEmbedderTests.java    From vividus with Apache License 2.0 4 votes vote down vote up
private EmbedderControls mockEmbedderControls(BatchedEmbedder spy)
{
    EmbedderControls mockedEmbedderControls = mock(EmbedderControls.class);
    doReturn(mockedEmbedderControls).when(spy).embedderControls();
    return mockedEmbedderControls;
}
 
Example #12
Source File: IJBConfigurator.java    From colibri-ui with Apache License 2.0 votes vote down vote up
void configure(EmbedderControls embedderControls, DriversSettings driversSettings);