org.jbehave.core.io.LoadFromClasspath Java Examples

The following examples show how to use org.jbehave.core.io.LoadFromClasspath. 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: 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 #2
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 #3
Source File: Stories.java    From attic-rave with Apache License 2.0 6 votes vote down vote up
@Override
public Configuration configuration() {
    Class<? extends Embeddable> embeddableClass = this.getClass();
    // Start from default ParameterConverters instance
    ParameterConverters parameterConverters = new ParameterConverters();
    // factory to allow parameter conversion and loading from external resources (used by StoryParser too)
    ExamplesTableFactory examplesTableFactory = new ExamplesTableFactory(new LocalizedKeywords(), new LoadFromClasspath(embeddableClass), parameterConverters);
    // add custom converters
    parameterConverters.addConverters(
            new DateConverter(new SimpleDateFormat("yyyy-MM-dd")),
            new ParameterConverters.EnumConverter()
    );
    return new MostUsefulConfiguration()
            .useStoryLoader(new LoadFromClasspath(embeddableClass))
            .useStoryParser(new RegexStoryParser(examplesTableFactory))
            .useStoryReporterBuilder(new StoryReporterBuilder()
                    .withCodeLocation(CodeLocations.codeLocationFromClass(embeddableClass))
                    .withDefaultFormats()
                    .withFormats(CONSOLE, TXT, HTML, XML))
            .useParameterConverters(parameterConverters);
}
 
Example #4
Source File: LogSearchStoryLocator.java    From ambari-logsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Get the proper story loader based on story location property (if empty or NONE - use story loading from classpath)
 * @param property Story location property (absolute path - folder)
 * @param clazz Class of the *Stories object
 */
public static StoryLoader getStoryLoader(String property, Class clazz) {
  boolean useExternalStoryLocation = useExternalStoryLocation(property);
  if (useExternalStoryLocation) {
    try {
      return new LoadFromRelativeFile(new URL("file://" + System.getProperty(property)));
    } catch (Exception e) {
      throw new RuntimeException("Cannot load story files from url: file://" + System.getProperty(property));
    }
  } else {
    return new LoadFromClasspath(clazz);
  }
}
 
Example #5
Source File: JBehaveTest.java    From Test-Driven-Java-Development-Second-Edition with MIT License 5 votes vote down vote up
@Override
public Configuration configuration() {
    Properties viewResources = new Properties();
    viewResources.put("decorateNonHtml", "true");
    return new MostUsefulConfiguration()
            .useStoryLoader(new LoadFromClasspath(this.getClass()))
            .useStoryPathResolver(new StoryResolver())
            .useStoryReporterBuilder(new StoryReporterBuilder()
                    .withViewResources(viewResources)
                    .withCodeLocation(
                            CodeLocations.codeLocationFromPath("build/reports/jbehave"))
                    .withFailureTrace(true)
                    .withDefaultFormats()
                    .withFormats(Format.CONSOLE, Format.HTML));
}
 
Example #6
Source File: UserRegistrationScenarios.java    From user-registration-V2 with Apache License 2.0 5 votes vote down vote up
@Override
public Configuration configuration() {
	LocalizedKeywords keywords = new LocalizedKeywords(new Locale("de"));
	return new MostUsefulConfiguration()
			.useKeywords(keywords)
			.useStepCollector(new MarkUnmatchedStepsAsPending(keywords))
			.useStoryParser(new RegexStoryParser(keywords))

			.useStoryLoader(new LoadFromClasspath(this.getClass()))
			.useFailureStrategy(new RethrowingFailure())
			.useStoryReporterBuilder(
					new StoryReporterBuilder().withKeywords(keywords)
							.withFormats(Format.HTML, Format.ANSI_CONSOLE)
							.withFailureTrace(true));
}
 
Example #7
Source File: ICanAddValues.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Configuration configuration() {
    return new MostUsefulConfiguration()
        // where to find the stories
        .useStoryLoader(new LoadFromClasspath(this.getClass()))  
        // CONSOLE and TXT reporting
        .useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE, Format.TXT)); 
}
 
Example #8
Source File: Stories.java    From metrics-kafka with Apache License 2.0 5 votes vote down vote up
@Override
public Configuration configuration() {
    return new MostUsefulConfiguration()
            .useStoryLoader(new LoadFromClasspath(this.getClass()))
            .useStoryReporterBuilder(new StoryReporterBuilder()
                    .withFormats(Format.TXT)
                    .withRelativeDirectory("../build/jbehave/"));
}
 
Example #9
Source File: AbstractStory.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public Configuration configuration() {
    return new MostUsefulConfiguration()
      .useStoryLoader(new LoadFromClasspath(this.getClass()))
      .useStoryReporterBuilder(new StoryReporterBuilder()
        .withCodeLocation(codeLocationFromClass(this.getClass()))
        .withFormats(CONSOLE));
}
 
Example #10
Source File: IncreaseStoryLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public Configuration configuration() {
    return new MostUsefulConfiguration()
      .useStoryLoader(new LoadFromClasspath(this.getClass()))
      .useStoryReporterBuilder(new StoryReporterBuilder()
        .withCodeLocation(codeLocationFromClass(this.getClass()))
        .withFormats(CONSOLE));
}
 
Example #11
Source File: UserRegistrationScenarios.java    From user-registration-V2 with Apache License 2.0 4 votes vote down vote up
@Override
public Configuration configuration() {
	return new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass()))
			.useFailureStrategy(new RethrowingFailure()).useStoryReporterBuilder(new StoryReporterBuilder()
					.withFormats(Format.HTML, Format.ANSI_CONSOLE).withFailureTrace(true));
}