How to use FeatureTracker class of io.cucumber.core.plugin package

Best Serenity Cucumber code snippet using io.cucumber.core.plugin.FeatureTracker

Source:SerenityReporter.java Github

copy

Full Screen

...194 URI featurePath = event.getTestCase().getUri();195 getContext().currentFeaturePathIs(featurePath);196 contextURISet.add(featurePath);197 setStepEventBus(featurePath);198 if (FeatureTracker.isNewFeature(event)) {199 // Shut down any drivers remaining open from a previous feature, if @singlebrowser is used.200 // Cucumber has no event to mark the start and end of a feature, so we need to do this here.201 if (RestartBrowserForEach.configuredIn(systemConfiguration.getEnvironmentVariables()).restartBrowserForANew(FEATURE)) {202 ThucydidesWebDriverSupport.closeCurrentDrivers();203 }204 FeatureTracker.startNewFeature(event);205 }206 String scenarioName = event.getTestCase().getName();207 TestSourcesModel.AstNode astNode = featureLoader.getAstNode(getContext().currentFeaturePath(), event.getTestCase().getLocation().getLine());208 Optional<Feature> currentFeature = featureFrom(featurePath);209 if ((astNode != null) && currentFeature.isPresent()) {210 getContext().setCurrentScenarioDefinitionFrom(astNode);211 //the sources are read in parallel, global current feature cannot be used212 String scenarioId = scenarioIdFrom(currentFeature.get().getName(), TestSourcesModel.convertToId(getContext().currentScenarioDefinition.getName()));213 boolean newScenario = !scenarioId.equals(getContext().getCurrentScenario());214 if (newScenario) {215 configureDriver(currentFeature.get(), getContext().currentFeaturePath());216 if (getContext().isAScenarioOutline()) {217 getContext().startNewExample();218 handleExamples(currentFeature.get(),...

Full Screen

Full Screen

Source:FeatureTracker.java Github

copy

Full Screen

1package io.cucumber.core.plugin;2import io.cucumber.plugin.event.TestCaseStarted;3import java.net.URI;4import java.util.*;5public class FeatureTracker {6 private static ThreadLocal<Set<URI>> STARTED_FEATURES = ThreadLocal.withInitial(HashSet::new);7 public static void startNewFeature(TestCaseStarted event) {8 STARTED_FEATURES.get().add(event.getTestCase().getUri());9 }10 public static boolean isNewFeature(TestCaseStarted event) {11 return !STARTED_FEATURES.get().contains(event.getTestCase().getUri());12 }13 public static boolean isASingleBrowserScenario(TestCaseStarted event) {14 return event.getTestCase().getTags().contains("@singlebrowser");15 }16}...

Full Screen

Full Screen

FeatureTracker

Using AI Code Generation

copy

Full Screen

1import io.cucumber.core.plugin.FeatureTracker;2import io.cucumber.core.plugin.Plugin;3import io.cucumber.plugin.event.EventPublisher;4import io.cucumber.plugin.event.TestRunFinished;5import io.cucumber.plugin.event.TestRunStarted;6public class FeatureTrackerPlugin implements Plugin {7 private FeatureTracker featureTracker;8 public void setEventPublisher(EventPublisher publisher) {9 publisher.registerHandlerFor(TestRunStarted.class, this::testRunStarted);10 publisher.registerHandlerFor(TestRunFinished.class, this::testRunFinished);11 }12 private void testRunStarted(TestRunStarted event) {13 featureTracker = new FeatureTracker();14 }15 private void testRunFinished(TestRunFinished event) {16 featureTracker.getFeatures().forEach(System.out::println);17 }18}19import io.cucumber.core.plugin.FeatureTracker;20import io.cucumber.core.plugin.Plugin;21import io.cucumber.plugin.event.EventPublisher;22import io.cucumber.plugin.event.TestRunFinished;23import io.cucumber.plugin.event.TestRunStarted;24public class FeatureTrackerPlugin implements Plugin {25 private FeatureTracker featureTracker;26 public void setEventPublisher(EventPublisher publisher) {27 publisher.registerHandlerFor(TestRunStarted.class, this::testRunStarted);28 publisher.registerHandlerFor(TestRunFinished.class, this::testRunFinished);29 }30 private void testRunStarted(TestRunStarted event) {31 featureTracker = new FeatureTracker();32 }33 private void testRunFinished(TestRunFinished event) {34 featureTracker.getFeatures().forEach(System.out::println);35 }36}37import io.cucumber.core.plugin.FeatureTracker;38import io.cucumber.core.plugin.Plugin;39import io.cucumber.plugin.event.EventPublisher;40import io.cucumber.plugin.event.TestRunFinished;41import io.cucumber.plugin.event.TestRunStarted;42public class FeatureTrackerPlugin implements Plugin {43 private FeatureTracker featureTracker;44 public void setEventPublisher(EventPublisher publisher) {45 publisher.registerHandlerFor(TestRunStarted.class, this::testRunStarted);46 publisher.registerHandlerFor(TestRunFinished.class, this::testRunFinished);47 }48 private void testRunStarted(TestRunStarted event) {49 featureTracker = new FeatureTracker();50 }51 private void testRunFinished(TestRunFinished event) {

Full Screen

Full Screen

FeatureTracker

Using AI Code Generation

copy

Full Screen

1package io.cucumber.core.plugin;2import io.cucumber.core.eventbus.EventBus;3import io.cucumber.core.eventbus.Subscribe;4import io.cucumber.core.options.RuntimeOptions;5import io.cucumber.core.plugin.FeatureTracker;6import io.cucumber.core.runtime.TimeServiceEventBus;7import io.cucumber.plugin.ConcurrentEventListener;8import io.cucumber.plugin.event.*;9import java.io.PrintStream;10import java.net.URI;11import java.util.*;12import static java.util.Collections.unmodifiableList;13import static java.util.Collections.unmodifiableMap;14public class FeatureTracker implements ConcurrentEventListener {15 private final Map<URI, Feature> features = new HashMap<>();16 private final EventBus bus;17 private final List<Feature> featuresList = new ArrayList<>();18 public FeatureTracker(TimeServiceEventBus bus, RuntimeOptions runtimeOptions) {19 this.bus = bus;20 bus.registerListener(this);21 }22 public void setEventPublisher(EventPublisher publisher) {23 publisher.registerHandlerFor(TestRunStarted.class, this::handleTestRunStarted);24 publisher.registerHandlerFor(TestRunFinished.class, this::handleTestRunFinished);25 publisher.registerHandlerFor(TestCaseStarted.class, this::handleTestCaseStarted);26 publisher.registerHandlerFor(TestCaseFinished.class, this::handleTestCaseFinished);27 publisher.registerHandlerFor(SnippetsSuggestedEvent.class, this::handleSnippetsSuggestedEvent);28 publisher.registerHandlerFor(TestSourceRead.class, this::handleTestSourceRead);29 }30 private void handleTestSourceRead(TestSourceRead event) {31 URI uri = event.uri();32 if (!features.containsKey(uri)) {33 features.put(uri, new Feature(uri));34 }35 }36 private void handleTestRunStarted(TestRunStarted event) {37 featuresList.clear();38 featuresList.addAll(features.values());39 }40 private void handleTestRunFinished(TestRunFinished event) {41 featuresList.clear();42 }43 private void handleTestCaseStarted(TestCaseStarted event) {44 URI uri = event.testCase().getUri();45 Feature feature = features.get(uri);46 feature.addTestCase(event.testCase());47 }48 private void handleTestCaseFinished(TestCaseFinished event) {49 URI uri = event.testCase().getUri();50 Feature feature = features.get(uri);51 feature.removeTestCase(event.testCase());52 }53 private void handleSnippetsSuggestedEvent(SnippetsSuggestedEvent event) {54 URI uri = event.getUri();55 Feature feature = features.get(uri);

Full Screen

Full Screen

FeatureTracker

Using AI Code Generation

copy

Full Screen

1public class FeatureTracker implements io.cucumber.core.plugin.FeatureTracker {2 private final io.cucumber.core.plugin.FeatureTracker featureTracker;3 private final io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();4 private FeatureTracker featureTracker = new FeatureTracker();5 private io.cucumber.core.plugin.FeatureTracker featureTracker;6 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();7 private io.cucumber.core.plugin.FeatureTracker featureTracker;8 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();9 private io.cucumber.core.plugin.FeatureTracker featureTracker;10 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();11 private io.cucumber.core.plugin.FeatureTracker featureTracker;12 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();13 private io.cucumber.core.plugin.FeatureTracker featureTracker;14 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();15 private io.cucumber.core.plugin.FeatureTracker featureTracker;16 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();17 private io.cucumber.core.plugin.FeatureTracker featureTracker;18 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();19 private io.cucumber.core.plugin.FeatureTracker featureTracker;20 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();21 private io.cucumber.core.plugin.FeatureTracker featureTracker;22 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();23 private io.cucumber.core.plugin.FeatureTracker featureTracker;24 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();25 private io.cucumber.core.plugin.FeatureTracker featureTracker;26 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();27 private io.cucumber.core.plugin.FeatureTracker featureTracker;28 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();29 private io.cucumber.core.plugin.FeatureTracker featureTracker;30 private io.cucumber.core.plugin.FeatureTracker featureTracker = new io.cucumber.core.plugin.FeatureTracker();

Full Screen

Full Screen

FeatureTracker

Using AI Code Generation

copy

Full Screen

1public class FeatureTracker implements ConcurrentEventListener {2 private static final Logger LOG = LoggerFactory.getLogger(FeatureTracker.class);3 private final Map<String, Feature> features = new HashMap<>();4 public void setEventPublisher(final EventPublisher publisher) {5 publisher.registerHandlerFor(TestStepStarted.class, this::handleTestStepStarted);6 publisher.registerHandlerFor(TestStepFinished.class, this::handleTestStepFinished);7 publisher.registerHandlerFor(TestCaseFinished.class, this::handleTestCaseFinished);8 }9 private void handleTestStepStarted(final TestStepStarted event) {10 final TestStep testStep = event.getTestStep();11 if (testStep instanceof PickleStepTestStep) {12 final PickleStepTestStep pickleStep = (PickleStepTestStep) testStep;13 final String featureName = pickleStep.getStep().getPickle().getUri();14 final Feature feature = features.computeIfAbsent(featureName, Feature::new);15 feature.startStep(pickleStep);16 }17 }18 private void handleTestStepFinished(final TestStepFinished event) {19 final TestStep testStep = event.getTestStep();20 if (testStep instanceof PickleStepTestStep) {21 final PickleStepTestStep pickleStep = (PickleStepTestStep) testStep;22 final String featureName = pickleStep.getStep().getPickle().getUri();23 final Feature feature = features.get(featureName);24 feature.finishStep(pickleStep);25 }26 }27 private void handleTestCaseFinished(final TestCaseFinished event) {28 final TestCase testCase = event.getTestCase();29 final String featureName = testCase.getUri();30 final Feature feature = features.get(featureName);31 if (feature != null) {32 feature.finishTestCase(testCase);33 }34 }35 private static class Feature {36 private final String name;37 private final Map<String, Step> steps = new HashMap<>();38 Feature(final String name) {39 this.name = name;40 }41 void startStep(final PickleStepTestStep pickleStep) {42 final String stepName = pickleStep.getStep().getText();

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 Cucumber automation tests on LambdaTest cloud grid

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

Most used methods in FeatureTracker

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful