How to use getConfiguredEmbedder method of net.serenitybdd.jbehave.runners.SerenityReportingRunner class

Best Serenity jBehave code snippet using net.serenitybdd.jbehave.runners.SerenityReportingRunner.getConfiguredEmbedder

Source:SerenityReportingRunner.java Github

copy

Full Screen

...71 return storyDescriptions;72 }73 protected Configuration getConfiguration() {74 if (configuration == null) {75 configuration = getConfiguredEmbedder().configuration();76 }77 return configuration;78 }79 public ExtendedEmbedder getConfiguredEmbedder() {80 if (configuredEmbedder == null) {81 configuredEmbedder = (ExtendedEmbedder) configurableEmbedder.configuredEmbedder();82 }83 return configuredEmbedder;84 }85 List<String> getStoryPaths() {86 if ((storyPaths == null) || (storyPaths.isEmpty())) {87 storyPaths = storyPathsFromRunnerClass();88 }89 return storyPaths;90 }91 private List<String> storyPathsFromRunnerClass() {92 try {93 List<String> storyPaths = new StoryPathsExtractor(configurableEmbedder).getStoryPaths();94 String storyFilter = getStoryFilterFrom(configurableEmbedder);95 return storyPaths.stream()96 .filter(story -> story.matches(storyFilter))97 .collect(Collectors.toList());98 } catch (Throwable e) {99 LOGGER.error("Could not load story paths", e);100 return Collections.emptyList();101 }102 }103 private String getStoryFilterFrom(ConfigurableEmbedder embedder) {104 String defaultStoryFilter = environmentVariables.getProperty(SerenityJBehaveSystemProperties.STORY_FILTER.getName(), ".*");105 Optional<Method> getStoryFilter = Arrays.stream(embedder.getClass().getMethods())106 .filter(method -> method.getName().equals("getStoryFilter"))107 .findFirst();108 if (getStoryFilter.isPresent()) {109 try {110 Optional<Object> storyFilterValue = Optional.ofNullable(getStoryFilter.get().invoke(embedder));111 return storyFilterValue.orElse(defaultStoryFilter).toString();112 } catch (IllegalAccessException | InvocationTargetException e) {113 LOGGER.warn("Could not invoke getStoryFilter() method on {}", embedder, e);114 }115 }116 return defaultStoryFilter;117 }118 private EnvironmentVariables environmentVariablesFrom(ConfigurableEmbedder configurableEmbedder) {119 if (configurableEmbedder instanceof SerenityStories) {120 return ((SerenityStories) configurableEmbedder).getEnvironmentVariables();121 } else {122 return Injectors.getInjector().getProvider(EnvironmentVariables.class).get();123 }124 }125 @Override126 public Description getDescription() {127 if (description == null) {128 description = Description.createSuiteDescription(configurableEmbedder.getClass());129 for (Description childDescription : getDescriptions()) {130 description.addChild(childDescription);131 }132 }133 return description;134 }135 private int testCount = 0;136 @Override137 public int testCount() {138 if (testCount == 0) {139 testCount = countStories();140 }141 return testCount;142 }143 @Override144 public void run(RunNotifier notifier) {145 beforeStoriesRun(getConfiguredEmbedder());146 getConfiguredEmbedder().embedderControls().doIgnoreFailureInView(getIgnoreFailuresInView());147 getConfiguredEmbedder().embedderControls().doIgnoreFailureInStories(getIgnoreFailuresInStories());148 getConfiguredEmbedder().embedderControls().useStoryTimeoutInSecs(getStoryTimeoutInSecs());149 getConfiguredEmbedder().embedderControls().useStoryTimeouts(getStoryTimeout());150 getConfiguredEmbedder().embedderControls().useThreads(getThreadCount());151 if (metaFiltersAreDefined()) {152 getConfiguredEmbedder().useMetaFilters(getMetaFilters());153 }154// if (!isRunningInMaven() && !isRunningInGradle()) {155 JUnitScenarioReporter junitReporter = new JUnitScenarioReporter(notifier, testCount(), getDescription(),156 getConfiguredEmbedder().configuration().keywords());157 // tell the reporter how to handle pending steps158 junitReporter.usePendingStepStrategy(getConfiguration().pendingStepStrategy());159 JUnitReportingRunner.recommendedControls(getConfiguredEmbedder());160 addToStoryReporterFormats(junitReporter);161// }162 try {163 getConfiguredEmbedder().runStoriesAsPaths(getStoryPaths());164 } catch (Throwable e) {165 throw new SerenityManagedException(e);166 } finally {167 getConfiguredEmbedder().generateCrossReference();168 }169 shutdownTestSuite();170 }171 private boolean isRunningInGradle() {172 return Stream.of(new Exception().getStackTrace()).anyMatch(elt -> elt.getClassName().startsWith("org.gradle"));173 }174 /**175 * Override this method to add custom configuration to the JBehave embedder object.176 *177 * @param configuredEmbedder178 */179 public void beforeStoriesRun(ExtendedEmbedder configuredEmbedder) {180 }181 private void shutdownTestSuite() {182 StepEventBus.getEventBus().testSuiteFinished();183 }184 List<CandidateSteps> getCandidateSteps() {185 if (candidateSteps == null) {186 StepMonitor originalStepMonitor = createCandidateStepsWithNoMonitor();187 createCandidateStepsWith(originalStepMonitor);188 }189 return candidateSteps;190 }191 private void createCandidateStepsWith(StepMonitor stepMonitor) {192 // reset step monitor and recreate candidate steps193 getConfiguration().useStepMonitor(stepMonitor);194 candidateSteps = buildCandidateSteps();195 candidateSteps.forEach(196 step -> step.configuration().useStepMonitor(stepMonitor)197 );198 }199 private StepMonitor createCandidateStepsWithNoMonitor() {200 StepMonitor usedStepMonitor = getConfiguration().stepMonitor();201 createCandidateStepsWith(new NullStepMonitor());202 return usedStepMonitor;203 }204 private List<CandidateSteps> buildCandidateSteps() {205 List<CandidateSteps> candidateSteps;206 InjectableStepsFactory stepsFactory = configurableEmbedder207 .stepsFactory();208 if (stepsFactory != null) {209 candidateSteps = stepsFactory.createCandidateSteps();210 } else {211 Embedder embedder = getConfiguredEmbedder();212 candidateSteps = embedder.candidateSteps();213 if (candidateSteps == null || candidateSteps.isEmpty()) {214 candidateSteps = embedder.stepsFactory().createCandidateSteps();215 }216 }217 return candidateSteps;218 }219 private void addToStoryReporterFormats(JUnitScenarioReporter junitReporter) {220 StoryReporterBuilder storyReporterBuilder = getConfiguration().storyReporterBuilder();221 StoryReporterBuilder.ProvidedFormat junitReportFormat222 = new StoryReporterBuilder.ProvidedFormat(junitReporter);223 storyReporterBuilder.withFormats(junitReportFormat);224 }225 private List<Description> buildDescriptionFromStories() {226 List<CandidateSteps> candidateSteps = getCandidateSteps();227 JUnitDescriptionGenerator descriptionGenerator = new JUnitDescriptionGenerator(candidateSteps, getConfiguration());228 List<Description> storyDescriptions = new ArrayList<>();229 addSuite(storyDescriptions, "BeforeStories");230 PerformableTree performableTree = createPerformableTree(candidateSteps, getStoryPaths());231 storyDescriptions.addAll(descriptionGenerator.createDescriptionFrom(performableTree));232 addSuite(storyDescriptions, "AfterStories");233 return storyDescriptions;234 }235 private int countStories() {236 JUnitDescriptionGenerator descriptionGenerator = new JUnitDescriptionGenerator(getCandidateSteps(), getConfiguration());237 return descriptionGenerator.getTestCases() + beforeAndAfterStorySteps();238 }239 private int beforeAndAfterStorySteps() {240 return 2;241 }242 private PerformableTree createPerformableTree(List<CandidateSteps> candidateSteps, List<String> storyPaths) {243 ExtendedEmbedder configuredEmbedder = this.getConfiguredEmbedder();244 configuredEmbedder.useMetaFilters(getMetaFilters());245 BatchFailures failures = new BatchFailures(configuredEmbedder.embedderControls().verboseFailures());246 PerformableTree performableTree = configuredEmbedder.performableTree();247 RunContext context = performableTree.newRunContext(getConfiguration(), candidateSteps,248 configuredEmbedder.embedderMonitor(), configuredEmbedder.metaFilter(), failures);249 performableTree.addStories(context, configuredEmbedder.storyManager().storiesOfPaths(storyPaths));250 return performableTree;251 }252 private void addSuite(List<Description> storyDescriptions, String name) {253 storyDescriptions.add(Description.createTestDescription(Object.class,254 name));255 }256 private boolean metaFiltersAreDefined() {257 String metaFilters = getMetafilterSetting();258 return !StringUtils.isEmpty(metaFilters);259 }260 private String getMetafilterSetting() {261 Optional<String> environmentMetafilters = getEnvironmentMetafilters();262 Optional<String> annotatedMetafilters = getAnnotatedMetafilters(testClass);263 Optional<String> thucAnnotatedMetafilters = getThucAnnotatedMetafilters(testClass);264 return environmentMetafilters.orElse(annotatedMetafilters.orElse(thucAnnotatedMetafilters.orElse("")));265 }266 private Optional<String> getEnvironmentMetafilters() {267 return Optional.ofNullable(environmentVariables.getProperty(SerenityJBehaveSystemProperties.METAFILTER.getName()));268 }269 /**270 * When Metafilter in thucydides package is removed, this method and callers will be removed271 *272 * @param testClass273 * @return274 */275 @Deprecated276 private Optional<String> getThucAnnotatedMetafilters(Class<? extends ConfigurableEmbedder> testClass) {277 return (testClass.getAnnotation(net.thucydides.jbehave.annotations.Metafilter.class) != null) ?278 Optional.of(testClass.getAnnotation(net.thucydides.jbehave.annotations.Metafilter.class).value()) : Optional.empty();279 }280 private Optional<String> getAnnotatedMetafilters(Class<? extends ConfigurableEmbedder> testClass) {281 return (testClass.getAnnotation(Metafilter.class) != null) ?282 Optional.of(testClass.getAnnotation(Metafilter.class).value()) : Optional.empty();283 }284 protected boolean getIgnoreFailuresInStories() {285 return environmentVariables.getPropertyAsBoolean(SerenityJBehaveSystemProperties.IGNORE_FAILURES_IN_STORIES.getName(), false);286 }287 protected int getStoryTimeoutInSecs() {288 return environmentVariables.getPropertyAsInteger(SerenityJBehaveSystemProperties.STORY_TIMEOUT_IN_SECS.getName(),289 (int) getConfiguredEmbedder().embedderControls().storyTimeoutInSecs());290 }291 protected int getThreadCount() {292 return environmentVariables.getPropertyAsInteger(SerenityJBehaveSystemProperties.JBEHAVE_THREADS.getName(), 1);293 }294 protected String getStoryTimeout() {295 return environmentVariables.getProperty(296 SerenityJBehaveSystemProperties.STORY_TIMEOUT.getName(),297 getConfiguredEmbedder().embedderControls().storyTimeouts());298 }299 protected List<String> getMetaFilters() {300 String metaFilters = getMetafilterSetting();301 return Lists.newArrayList(Splitter.on(Pattern.compile(",")).trimResults().omitEmptyStrings().split(metaFilters));302 }303 protected boolean getIgnoreFailuresInView() {304 return environmentVariables.getPropertyAsBoolean(SerenityJBehaveSystemProperties.IGNORE_FAILURES_IN_VIEW.getName(), true);305 }306 public boolean isRunningInMaven() {307 return Stream.of(new Exception().getStackTrace()).anyMatch(elt -> elt.getClassName().contains("maven"));308 }309}...

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1package net.serenitybdd.jbehave.runners;2import net.thucydides.core.guice.Injectors;3import net.thucydides.core.util.EnvironmentVariables;4import org.jbehave.core.embedder.Embedder;5import org.jbehave.core.embedder.EmbedderControls;6public class SerenityReportingRunner extends SerenityRunner {7 public SerenityReportingRunner(Class<?> storyClass) throws Throwable {8 super(storyClass);9 }10 protected Embedder configuredEmbedder() throws Throwable {11 return getConfiguredEmbedder();12 }13 protected Embedder getConfiguredEmbedder() throws Throwable {14 Embedder embedder = new Embedder();15 embedder.useEmbedderControls(embedderControls());16 embedder.useMetaFilters(metaFilters());17 embedder.useCandidateSteps(candidateSteps());18 embedder.useStoryControls(storyControls());19 embedder.useStoryLoader(storyLoader());20 embedder.useStoryParser(storyParser());21 embedder.useStoryReporterBuilder(storyReporterBuilder());22 embedder.useViewGenerator(viewGenerator());23 return embedder;24 }25 protected EmbedderControls embedderControls() {26 return new EmbedderControls();27 }28 protected String metaFilters() {29 return "";30 }31 protected EnvironmentVariables environmentVariables() {32 return Injectors.getInjector().getInstance(EnvironmentVariables.class);33 }34}35[INFO] --- maven-compiler-plugin:3.6.2:compile (default-compile) @ automation ---

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1 public Embedder configuredEmbedder() {2 Embedder embedder = super.configuredEmbedder();3 embedder.useEmbedderControls(new EmbedderControls().doIgnoreFailureInStories(true).doIgnoreFailureInView(true));4 embedder.useMetaFilters(Arrays.asList("-skip"));5 return embedder;6 }7}8package runner;9import net.serenitybdd.jbehave.SerenityStories;10import net.serenitybdd.jbehave.SerenityStory;11import net.thucydides.core.annotations.Steps;12import org.jbehave.core.annotations.*;13import org.jbehave.core.model.ExamplesTable;14import org.jbehave.core.model.Meta;15import org.jbehave.core.model.Story;16import org.jbehave.core.steps.CandidateSteps;17import org.jbehave.core.steps.InjectableStepsFactory;18import org.jbehave.core.steps.InstanceStepsFactory;19import steps.EndUserSteps;20import java.util.List;21import java.util.Map;22public class SerenityRunner extends SerenityStories {23 public InjectableStepsFactory stepsFactory() {24 return new InstanceStepsFactory(configuration(), new EndUserSteps());25 }26}27package steps;28import net.thucydides.core.annotations.Step;29import net.thucydides.core.annotations.Steps;30import net.thucydides.core.steps.ScenarioSteps;31import org.jbehave.core.annotations.*;32import org.jbehave.core.model.ExamplesTable;33import org.jbehave.core.model.Meta;34import org.jbehave.core.model.Story;35import org.jbehave.core

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1 public Embedder configuredEmbedder() {2 return getConfiguredEmbedder();3 }4 public InjectableStepsFactory stepsFactory() {5 return new InstanceStepsFactory(configuration(), new JBehaveSteps());6 }7 protected List<String> storyPaths() {8 return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", "");9 }10 public Configuration configuration() {11 return super.configuration()12 .useStoryLoader(new LoadFromClasspath(this.getClass()))13 .useStoryReporterBuilder(new StoryReporterBuilder()14 .withCodeLocation(CodeLocations.codeLocationFromClass(this.getClass()))15 .withFormats(Format.CONSOLE, Format.TXT, Format.HTML)16 .withFailureTrace(true)17 .withFailureTraceCompression(true)18 .withDefaultFormats()19 .withViewResources(viewResources())20 .withCrossReference(xref()));21 }22 private ViewResources viewResources() {23 return new ViewResources().useResource("decorator", "/ftl/jbehave-report-decorator.ftl");24 }25 private CrossReference xref() {26 return new CrossReference()27 .withJsonOnly()28 .withOutputAfterEachStory(true)29 .withDataOnly()30 .withOutputDirectory("target/jbehave/view");31 }32}33package net.serenitybdd.jbehave;34import net.thucydides.core.steps.StepEventBus;35import org.jbehave.core.annotations.AfterScenario;36import org.jbehave.core.annotations.AfterStories;37import org.jbehave.core.annotations.AfterStory;38import org.jbehave.core.annotations.BeforeScenario;39import org.jbehave.core.annotations.BeforeStories;40import org.jbehave.core.annotations.BeforeStory;41import org.jbehave.core.annotations.ScenarioType;42import org.jbehave.core.annotations.UsingSteps;43import org.jbehave.core.configuration.Configuration;44import org.jbehave.core.configuration.MostUsefulConfiguration;45import org.jbehave.core.embedder.Embedder;46import org.jbehave.core.embedder.EmbedderControls;47import org.jbehave.core.embedder.StoryControls;48import org.jbehave.core.embedder.StoryManager;49import org.jbehave.core.embedder.executors.SameThreadExecutors;50import org.jbehave.core.failures.BatchFailures;51import org.jbehave.core.failures.UUIDExceptionWrapper;52import

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1package net.serenitybdd.jbehave.runners;2import net.thucydides.core.steps.StepEventBus;3import org.jbehave.core.configuration.Configuration;4import org.jbehave.core.embedder.Embedder;5import org.jbehave.core.embedder.EmbedderControls;6import org.jbehave.core.embedder.MetaFilter;7import org.jbehave.core.embedder.MetaFilter.AllowMetaFilter;8import org.jbehave.core.embedder.MetaFilter.AllowMetaByProperty;9import org.jbehave.core.embedder.MetaFilter.DisallowMetaFilter;10import org.jbehave.core.embedder.MetaFilter.DisallowMetaByProperty;11import org.jbehave.core.embedder.MetaFilter.AllowIfNoMeta;12import org.jbehave.core.embedder.MetaFilter.DisallowIfNoMeta;13import org.jbehave.core.embedder.MetaFilter.AllowIfMetaNamed;14import org.jbehave.core.embedder.MetaFilter.DisallowIfMetaNamed;15import org.jbehave.core.embedder.MetaFilter.AllowIfMetaAnnotated;16import org.jbehave.core.embedder.MetaFilter.DisallowIfMetaAnnotated;17import org.jbehave.core.embedder.MetaFilter.AllowIfMetaProperty;18import org.jbehave.core.embedder.MetaFilter.DisallowIfMetaProperty;19import org.jbehave.core.embedder.MetaFilter.AllowIfStoryMetaAnnotated;20import org.jbehave.core.embedder.MetaFilter.DisallowIfStoryMetaAnnotated;21import org.jbehave.core.embedder.MetaFilter.AllowIfStoryMetaProperty;22import org.jbehave.core.embedder.MetaFilter.DisallowIfStoryMetaProperty;23import org.jbehave.core.embedder.MetaFilter.AllowIfStoryMetaNamed;24import org.jbehave.core.embedder.MetaFilter.DisallowIfStoryMetaNamed;25import org.jbehave.core.embedder.MetaFilter.AllowIfStoryMetaTagged;26import org.jbehave.core.embedder.MetaFilter.DisallowIfStoryMetaTagged;27import org.jbehave.core.embedder.MetaFilter.AllowIfMetaTagged;28import org.jbehave.core.embedder.MetaFilter.DisallowIfMetaTagged;29import org.jbehave.core.embedder.MetaFilter.AllowIfMetaNotTagged;30import org.jbehave.core.embedder.MetaFilter.DisallowIfMetaNotTagged;31import org.jbehave.core.embedder.MetaFilter.AllowIfStoryMetaNotTagged;32import org.jbehave.core.embedder.MetaFilter.DisallowIfStoryMetaNotTag

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1net.serenitybdd.jbehave.SerenityStories stories = getConfiguredEmbedder().getEmbedderControls().useStoryTimeouts("300");2stories.run();3net.serenitybdd.jbehave.SerenityStories stories = getConfiguredEmbedder().getEmbedderControls().useStoryTimeouts("300");4stories.run();5net.serenitybdd.jbehave.SerenityStories stories = getConfiguredEmbedder().getEmbedderControls().useStoryTimeouts("300");6stories.run();7net.serenitybdd.jbehave.SerenityStories stories = getConfiguredEmbedder().getEmbedderControls().useStoryTimeouts("300");8stories.run();

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1import net.serenitybdd.jbehave.runners.SerenityReportingRunner;2import org.jbehave.core.embedder.Embedder;3import org.jbehave.core.io.StoryPathResolver;4import org.junit.runner.RunWith;5import java.util.List;6@RunWith(SerenityReportingRunner.class)7public class MyStory {8 public static void main(String[] args) {9 Embedder embedder = new SerenityReportingRunner(MyStory.class).getConfiguredEmbedder();10 List<String> storyPaths = embedder.configuration().storyPathResolver().resolve("src/test/resources/");11 System.out.println(storyPaths);12 }13}14package net.serenitybdd.jbehave.runners;15import org.jbehave.core.embedder.Embedder;16import org.jbehave.core.embedder.MetaFilter;17import org.jbehave.core.embedder.MetaFilter.MetaByProperty;18import org.jbehave.core.embedder.MetaFilter.MetaByTag;19import org.jbehave.core.embedder.MetaFilter.MetaByTagname;20import org.jbehave.core.embedder.MetaFilter.MetaByTagName;21import org.jbehave.core.embedder.MetaFilter.MetaByTags;22import org.jbehave.core.embedder.MetaFilter.MetaByTagsInMap;23import org.jbehave.core.embedder.MetaFilter.MetaByTagsInSet;24import org.jbehave.core.embedder.MetaFilter.MetaByTagsProperty;25import org.jbehave.core.embedder.MetaFilter.MetaByTagsPropertyInMap;26import org.jbehave.core.embedder.MetaFilter.MetaByTagsProperty

Full Screen

Full Screen

getConfiguredEmbedder

Using AI Code Generation

copy

Full Screen

1 public Embedder configuredEmbedder() {2 Embedder embedder = super.getConfiguredEmbedder();3 this.serenityRunner.setEmbedder(embedder);4 return embedder;5 }6}7package net.serenitybdd.jbehave.runners;8import org.jbehave.core.embedder.Embedder;9public class SerenityReportingRunner extends SerenityRunner {10 public SerenityReportingRunner(Class<?> clazz) throws Throwable {11 super(clazz);12 }13 public Embedder configuredEmbedder() {14 return super.getConfiguredEmbedder();15 }16}17package net.serenitybdd.jbehave.runners;18import org.jbehave.core.embedder.Embedder;19public class SerenityRunner extends AbstractSerenityRunner {20 public SerenityRunner(Class<?> clazz) throws Throwable {21 super(clazz);22 }23 public Embedder configuredEmbedder() {24 return this.embedder;25 }26}27package net.serenitybdd.jbehave.runners;28import java.io.File;29import java.io.IOException;30import java.util.ArrayList;31import java.util.List;32import net.thucydides.core.ThucydidesSystemProperty;33import net.thucydides.core.model.TestOutcome;34import net.thucydides.core.reports.TestOutcomes;35import net.thucydides.core.util.EnvironmentVariables;36import net.thucydides.core.util.Inflector;37import net.thucydides.core.util.NameConverter;38import net.thucydides

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Serenity jBehave automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful