How to use metaFilters method of net.serenitybdd.jbehave.embedders.ExtendedEmbedder class

Best Serenity jBehave code snippet using net.serenitybdd.jbehave.embedders.ExtendedEmbedder.metaFilters

Source:SerenityReportingRunner.java Github

copy

Full Screen

...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

Source:ExtendedEmbedder.java Github

copy

Full Screen

...121 public StoryManager storyManager() {122 return embedder.storyManager();123 }124 @Override125 public List<String> metaFilters() {126 return embedder.metaFilters();127 }128 @Override129 public Map<String, MetaFilter.MetaMatcher> metaMatchers() {130 return embedder.metaMatchers();131 }132 @Override133 public MetaFilter metaFilter() {134 return embedder.metaFilter();135 }136 @Override137 public PerformableTree performableTree() {138 return embedder.performableTree();139 }140 @Override141 public Properties systemProperties() {142 return embedder.systemProperties();143 }144 @Override145 public StoryTimeouts.TimeoutParser[] timeoutParsers() {146 return embedder.timeoutParsers();147 }148 @Override149 public void useClassLoader(EmbedderClassLoader classLoader) {150 embedder.useClassLoader(classLoader);151 }152 @Override153 public void useConfiguration(Configuration configuration) {154 embedder.useConfiguration(configuration);155 }156 @Override157 public void useCandidateSteps(List<CandidateSteps> candidateSteps) {158 embedder.useCandidateSteps(candidateSteps);159 }160 @Override161 public void useStepsFactory(InjectableStepsFactory stepsFactory) {162 embedder.useStepsFactory(stepsFactory);163 }164 @Override165 public void useEmbedderControls(EmbedderControls embedderControls) {166 embedder.useEmbedderControls(embedderControls);167 }168 @Override169 public void useEmbedderFailureStrategy(EmbedderFailureStrategy failureStategy) {170 embedder.useEmbedderFailureStrategy(failureStategy);171 }172 @Override173 public void useEmbedderMonitor(EmbedderMonitor embedderMonitor) {174 embedder.useEmbedderMonitor(embedderMonitor);175 }176 @Override177 public void useExecutorService(ExecutorService executorService) {178 embedder.useExecutorService(executorService);179 }180 @Override181 public void useMetaFilters(List<String> metaFilters) {182 embedder.useMetaFilters(metaFilters);183 }184 @Override185 public void useMetaMatchers(Map<String, MetaFilter.MetaMatcher> metaMatchers) {186 embedder.useMetaMatchers(metaMatchers);187 }188 @Override189 public void usePerformableTree(PerformableTree performableTree) {190 embedder.usePerformableTree(performableTree);191 }192 @Override193 public void useSystemProperties(Properties systemProperties) {194 embedder.useSystemProperties(systemProperties);195 }196 @Override...

Full Screen

Full Screen

Source:ReportingEmbedderMonitor.java Github

copy

Full Screen

...90 @Override91 public void annotatedInstanceNotOfType(Object annotatedInstance, Class<?> type) {92 }93 @Override94 public void mappingStory(String storyPath, List<String> metaFilters) {95 }96 @Override97 public void generatingMapsView(File outputDirectory, StoryMaps storyMaps, Properties viewProperties) {98 }99 @Override100 public void mapsViewGenerationFailed(File outputDirectory, StoryMaps storyMaps, Properties viewProperties, Throwable cause) {101 }102 @Override103 public void generatingNavigatorView(File outputDirectory, Properties viewResources) {104 }105 @Override106 public void navigatorViewGenerationFailed(File outputDirectory, Properties viewResources, Throwable cause) {107 }108 @Override...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful