org.jbehave.core.steps.InjectableStepsFactory Java Examples

The following examples show how to use org.jbehave.core.steps.InjectableStepsFactory. 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: BddStepsCounterTests.java    From vividus with Apache License 2.0 6 votes vote down vote up
private void mockStepsAndCandidates(String resourceLocation, List<String> steps, List<StepCandidate> stepCandidates)
        throws Exception
{
    PowerMockito.whenNew(BddStepsCounter.class).withNoArguments().thenReturn(bddStepsCounter);
    PowerMockito.doNothing().when(Vividus.class, "init");
    when(BeanFactory.getBean(StoryLoader.class)).thenReturn(storyLoader);
    when(BeanFactory.getBean(IPathFinder.class)).thenReturn(pathFinder);
    when(BeanFactory.getBean(ExtendedConfiguration.class)).thenReturn(configuration);
    when(configuration.keywords()).thenReturn(keywords);
    when(keywords.and()).thenReturn(AND);
    when(keywords.ignorable()).thenReturn(COMMENT);
    when(configuration.storyParser()).thenReturn(storyParser);
    String path = "";
    when(pathFinder.findPaths(argThat(arg -> resourceLocation.equals(arg.getResourceLocation())))).thenReturn(
            List.of(path));
    String storyText = "";
    when(storyLoader.loadResourceAsText(path)).thenReturn(storyText);
    when(storyParser.parseStory(any(String.class))).thenReturn(story);
    when(story.getScenarios()).thenReturn(List.of(scenario));
    when(scenario.getSteps()).thenReturn(steps);
    when(BeanFactory.getBean(InjectableStepsFactory.class)).thenReturn(stepFactory);
    when(stepFactory.createCandidateSteps()).thenReturn(List.of(candidateSteps));
    when(candidateSteps.listCandidates()).thenReturn(stepCandidates);
}
 
Example #2
Source File: BddStepPrinterTests.java    From vividus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private List<String> mockStepCandidates() throws Exception
{
    mockStatic(Vividus.class);
    PowerMockito.doNothing().when(Vividus.class, "init");
    mockStatic(BeanFactory.class);
    InjectableStepsFactory stepsFactory = mock(InjectableStepsFactory.class);
    when(BeanFactory.getBean(InjectableStepsFactory.class)).thenReturn(stepsFactory);
    CandidateSteps candidateSteps = mock(CandidateSteps.class);
    when(stepsFactory.createCandidateSteps()).thenReturn(List.of(candidateSteps));
    StepCandidate stepCandidate1 = mockStepCandidate("Given", "initial state is '$status'", "simpleMethod");
    StepCandidate stepCandidate2 = mockStepCandidate("When", "I do '$action'", "deprecatedMethod");
    StepCandidate stepCandidate3 = mockStepCandidate("Then", "I perform '$verification'", (Method) null);
    when(candidateSteps.listCandidates()).thenReturn(List.of(stepCandidate1, stepCandidate2, stepCandidate3));
    return List.of("                         Given initial state is '$status'",
            " DEPRECATED              When I do '$action'",
            " COMPOSITE IN STEPS FILE Then I perform '$verification'");
}
 
Example #3
Source File: LogSearchBackendStories.java    From ambari-logsearch with Apache License 2.0 6 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
  return new InstanceStepsFactory(configuration(),
    new LogSearchDockerSteps(),
    new SolrSteps(),
    new LogSearchApiSteps(),
    new LogSearchConfigApiSteps());
}
 
Example #4
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 #5
Source File: BddStepPrinter.java    From vividus with Apache License 2.0 5 votes vote down vote up
private static Set<Step> getSteps()
{
    InjectableStepsFactory stepFactory = BeanFactory.getBean(InjectableStepsFactory.class);
    return stepFactory.createCandidateSteps()
            .stream()
            .map(CandidateSteps::listCandidates)
            .flatMap(List::stream)
            .map(BddStepPrinter::createStepFrom)
            .collect(Collectors.toCollection(TreeSet::new));
}
 
Example #6
Source File: BddStepsCounter.java    From vividus with Apache License 2.0 5 votes vote down vote up
private void fillStepCandidates()
{
    InjectableStepsFactory stepFactory = BeanFactory.getBean(InjectableStepsFactory.class);
    for (CandidateSteps candidateSteps : stepFactory.createCandidateSteps())
    {
        stepCandidates.addAll(candidateSteps.listCandidates());
    }
}
 
Example #7
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 #8
Source File: Stories.java    From attic-rave with Apache License 2.0 5 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(),
            new CommonSteps(),
            new PeopleSteps()
    );
}
 
Example #9
Source File: UserRegistrationScenarios.java    From user-registration-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
	return new InstanceStepsFactory(configuration(), new UserRegistrationSteps());
}
 
Example #10
Source File: UserRegistrationScenarios.java    From user-registration-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
	return new InstanceStepsFactory(configuration(),
			new UserRegistrationSteps());
}
 
Example #11
Source File: IncreaseStoryLiveTest.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(), new IncreaseSteps());
}
 
Example #12
Source File: GenericRunner.java    From vividus with Apache License 2.0 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory()
{
    return embedder.stepsFactory();
}
 
Example #13
Source File: AbstractStory.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(), stepInstance());
}
 
Example #14
Source File: Stories.java    From metrics-kafka with Apache License 2.0 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(), new MetricsReportingSteps());
}
 
Example #15
Source File: ICanAddValues.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {        
    // varargs, can have more that one steps classes
    return new InstanceStepsFactory(configuration(),new AdderSteps());
}
 
Example #16
Source File: AbstractSpringJBehaveStory.java    From angularjs-springmvc-sample-boot with Apache License 2.0 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(), getSteps());
}
 
Example #17
Source File: JBehaveTest.java    From Test-Driven-Java-Development-Second-Edition with MIT License 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(), new WebSteps());
}
 
Example #18
Source File: Runner.java    From Test-Driven-Java-Development-Second-Edition with MIT License 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
    return new InstanceStepsFactory(configuration(), new Steps());
}
 
Example #19
Source File: LogSearchUIStories.java    From ambari-logsearch with Apache License 2.0 4 votes vote down vote up
@Override
public InjectableStepsFactory stepsFactory() {
  Configuration configuration = configuration();
  return new InstanceStepsFactory(configuration, new LogSearchDockerSteps(), new LogSearchUISteps(driverProvider),
    new WebDriverScreenshotOnFailure(driverProvider, configuration.storyReporterBuilder()));
}
 
Example #20
Source File: BatchedEmbedder.java    From vividus with Apache License 2.0 4 votes vote down vote up
public void setStepFactory(InjectableStepsFactory stepsFactory)
{
    useStepsFactory(stepsFactory);
}
 
Example #21
Source File: StepExamplesTableParser.java    From vividus with Apache License 2.0 4 votes vote down vote up
public StepExamplesTableParser(ExtendedConfiguration configuration, InjectableStepsFactory stepsFactory)
{
    this.configuration = configuration;
    this.stepsFactory = stepsFactory;
}