How to use usingThreads method of net.serenitybdd.jbehave.embedders.monitors.ReportingEmbedderMonitor class

Best Serenity jBehave code snippet using net.serenitybdd.jbehave.embedders.monitors.ReportingEmbedderMonitor.usingThreads

Run Serenity jBehave automation tests on LambdaTest cloud grid

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

copy
1package net.serenitybdd.jbehave.embedders.monitors;
2
3import net.serenitybdd.core.di.WebDriverInjectors;
4import net.serenitybdd.jbehave.SerenityReporter;
5import net.serenitybdd.jbehave.embedders.ExtendedEmbedder;
6import net.thucydides.core.guice.Injectors;
7import net.thucydides.core.util.EnvironmentVariables;
8import net.thucydides.core.webdriver.DriverConfiguration;
9import org.jbehave.core.embedder.EmbedderControls;
10import org.jbehave.core.embedder.EmbedderMonitor;
11import org.jbehave.core.embedder.MetaFilter;
12import org.jbehave.core.failures.BatchFailures;
13import org.jbehave.core.model.*;
14import org.jbehave.core.reporters.ReportsCount;
15import org.slf4j.Logger;
16import org.slf4j.LoggerFactory;
17
18import java.io.File;
19import java.util.Collections;
20import java.util.List;
21import java.util.Properties;
22import java.util.Set;
23import java.util.concurrent.ConcurrentHashMap;
24import java.util.concurrent.ExecutorService;
25
26/**
27 * User: YamStranger
28 * Date: 3/25/16
29 * Time: 6:35 PM
30 */
31public class ReportingEmbedderMonitor implements EmbedderMonitor {
32    private static final Logger logger = LoggerFactory.getLogger(ReportingEmbedderMonitor.class);
33    private SerenityReporter reporter;
34    private ExtendedEmbedder embedder;
35    private final DriverConfiguration configuration;
36    private final Set<String> processedStories=Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
37
38
39    public ReportingEmbedderMonitor(final ExtendedEmbedder embedder) {
40        this(configuration(), embedder);
41    }
42
43    public ReportingEmbedderMonitor(final DriverConfiguration configuration,
44                                    final ExtendedEmbedder embedder) {
45        this.configuration = configuration;
46        this.embedder = embedder;
47    }
48
49
50    @Override
51    public void runningEmbeddable(String name) {
52    }
53
54    @Override
55    public void embeddableFailed(String name, Throwable cause) {
56    }
57
58    @Override
59    public void embeddableNotConfigurable(String name) {
60    }
61
62    @Override
63    public void embeddablesSkipped(List<String> classNames) {
64    }
65
66    @Override
67    public void metaNotAllowed(Meta meta, MetaFilter filter) {
68    }
69
70    @Override
71    public void storyFailed(String path, Throwable cause) {
72    }
73
74    @Override
75    public void storiesSkipped(List<String> storyPaths) {
76    }
77
78    @Override
79    public void scenarioNotAllowed(Scenario scenario, MetaFilter filter) {
80    }
81
82    @Override
83    public void batchFailed(BatchFailures failures) {
84    }
85
86    @Override
87    public void beforeOrAfterStoriesFailed() {
88    }
89
90    @Override
91    public void generatingReportsView(File outputDirectory, List<String> formats, Properties viewProperties) {
92    }
93
94    @Override
95    public void reportsViewGenerationFailed(File outputDirectory, List<String> formats, Properties viewProperties, Throwable cause) {
96    }
97
98    @Override
99    public void reportsViewGenerated(ReportsCount count) {
100    }
101
102    @Override
103    public void reportsViewFailures(ReportsCount count) {
104    }
105
106    @Override
107    public void reportsViewNotGenerated() {
108    }
109
110    @Override
111    public void runningWithAnnotatedEmbedderRunner(String className) {
112    }
113
114    @Override
115    public void annotatedInstanceNotOfType(Object annotatedInstance, Class<?> type) {
116    }
117
118    @Override
119    public void mappingStory(String storyPath, List<String> metaFilters) {
120    }
121
122    @Override
123    public void generatingMapsView(File outputDirectory, StoryMaps storyMaps, Properties viewProperties) {
124    }
125
126    @Override
127    public void mapsViewGenerationFailed(File outputDirectory, StoryMaps storyMaps, Properties viewProperties, Throwable cause) {
128    }
129
130    @Override
131    public void generatingNavigatorView(File outputDirectory, Properties viewResources) {
132    }
133
134    @Override
135    public void navigatorViewGenerationFailed(File outputDirectory, Properties viewResources, Throwable cause) {
136    }
137
138    @Override
139    public void navigatorViewNotGenerated() {
140    }
141
142    @Override
143    public void processingSystemProperties(Properties properties) {
144    }
145
146    @Override
147    public void systemPropertySet(String name, String value) {
148    }
149
150    @Override
151    public void storyTimeout(Story story, StoryDuration storyDuration) {
152    }
153
154    @Override
155    public void usingThreads(int threads) {
156    }
157
158    @Override
159    public void usingExecutorService(ExecutorService executorService) {
160    }
161
162    @Override
163    public void usingControls(EmbedderControls embedderControls) {
164    }
165
166    @Override
167    public void invalidTimeoutFormat(String path) {
168    }
169
170    @Override
171    public void usingTimeout(String path, long timeout) {
172    }
173
174    @Override
175    public void runningStory(String path) {
176        logger.info("{}story running with path {}", this.hashCode(), path);
177        final Story story = embedder.findStory(path);
178        if (story == null) {
179            logger.error("can not find any story by path {}", path);
180        } else {
181            includeInReportSkippedAndIgnoredAndWip(story);
182        }
183    }
184
185
186    @Override
187    public void storiesNotAllowed(List<Story> notAllowed, MetaFilter filter) {
188        logger.debug("processing stories Not Allowed {}", notAllowed);
189        for (final Story story : notAllowed) {
190            includeInReportSkippedAndIgnoredAndWip(story);
191        }
192    }
193
194    @Override
195    public void storiesNotAllowed(List<Story> notAllowed, MetaFilter filter, boolean verbose) {
196        logger.debug("processing stories Not Allowed {}", notAllowed);
197        for (final Story story : notAllowed) {
198            includeInReportSkippedAndIgnoredAndWip(story);
199        }
200    }
201
202    private void includeInReportSkippedAndIgnoredAndWip(final Story story) {
203        final SerenityReporter reporter = reporter();
204        this.processedStories.addAll(
205                reporter.processExcludedByFilter(story, this.processedStories)
206        );
207    }
208
209    public synchronized SerenityReporter reporter() {
210        if (this.reporter == null) {
211            this.reporter = new SerenityReporter(this.configuration);
212        }
213        return reporter;
214    }
215
216
217    private static DriverConfiguration configuration() {
218        DriverConfiguration<DriverConfiguration> configuration =
219                WebDriverInjectors.getInjector().getInstance(DriverConfiguration.class);
220        EnvironmentVariables variables =
221                Injectors.getInjector().getProvider(EnvironmentVariables.class).get().copy();
222        if (variables != null) {
223            configuration = configuration.withEnvironmentVariables(variables);
224        }
225        return configuration;
226    }
227}
228
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)