How to use filter method of net.serenitybdd.cucumber.suiteslicing.WeightedCucumberScenarios class

Best Serenity Cucumber code snippet using net.serenitybdd.cucumber.suiteslicing.WeightedCucumberScenarios.filter

Source:CucumberSerenityRunner.java Github

copy

Full Screen

1package io.cucumber.junit;2import com.mengweijin.tester.serenity.SerenityCucumberMain;3import io.cucumber.core.eventbus.EventBus;4import io.cucumber.core.feature.FeatureParser;5import io.cucumber.core.filter.Filters;6import io.cucumber.core.gherkin.Feature;7import io.cucumber.core.gherkin.Pickle;8import io.cucumber.core.options.*;9import io.cucumber.core.plugin.PluginFactory;10import io.cucumber.core.plugin.Plugins;11import io.cucumber.core.plugin.SerenityReporter;12import io.cucumber.core.resource.ClassLoaders;13import io.cucumber.core.runtime.Runtime;14import io.cucumber.core.runtime.*;15import io.cucumber.plugin.Plugin;16import io.cucumber.tagexpressions.Expression;17import net.serenitybdd.cucumber.suiteslicing.CucumberSuiteSlicer;18import net.serenitybdd.cucumber.suiteslicing.ScenarioFilter;19import net.serenitybdd.cucumber.suiteslicing.TestStatistics;20import net.serenitybdd.cucumber.suiteslicing.WeightedCucumberScenarios;21import net.serenitybdd.cucumber.util.PathUtils;22import net.serenitybdd.cucumber.util.Splitter;23import net.thucydides.core.ThucydidesSystemProperty;24import net.thucydides.core.guice.Injectors;25import net.thucydides.core.util.EnvironmentVariables;26import net.thucydides.core.webdriver.Configuration;27import org.junit.runner.Description;28import org.junit.runner.manipulation.NoTestsRemainException;29import org.junit.runner.notification.RunNotifier;30import org.junit.runners.ParentRunner;31import org.junit.runners.model.InitializationError;32import org.junit.runners.model.RunnerScheduler;33import org.junit.runners.model.Statement;34import org.slf4j.Logger;35import org.slf4j.LoggerFactory;36import java.io.File;37import java.net.URI;38import java.time.Clock;39import java.util.*;40import java.util.concurrent.atomic.AtomicInteger;41import java.util.function.Function;42import java.util.function.Predicate;43import java.util.function.Supplier;44import static io.cucumber.junit.FileNameCompatibleNames.uniqueSuffix;45import static java.util.stream.Collectors.groupingBy;46import static java.util.stream.Collectors.toList;47import static net.thucydides.core.ThucydidesSystemProperty.*;48/**49 * Glue code for running Cucumber via Serenity.50 * Sets up Serenity reporting and instrumentation.51 */52public class CucumberSerenityRunner extends ParentRunner<ParentRunner<?>> {53    private static final Logger LOGGER = LoggerFactory.getLogger(CucumberSerenityRunner.class);54    private List<ParentRunner<?>> children = new ArrayList<ParentRunner<?>>();55    private final EventBus bus;56    private static ThreadLocal<RuntimeOptions> RUNTIME_OPTIONS = new ThreadLocal<>();57    private final List<Feature> features;58    private final Plugins plugins;59    private final CucumberExecutionContext context;60    private boolean multiThreadingAssumed = false;61    /**62     * Constructor called by JUnit.63     *64     * @param clazz the class with the @RunWith annotation.65     * @throws InitializationError if there is another problem66     */67    public CucumberSerenityRunner(Class clazz) throws InitializationError {68        super(clazz);69        Assertions.assertNoCucumberAnnotatedMethods(clazz);70        // Parse the options early to provide fast feedback about invalid options71        RuntimeOptions propertiesFileOptions = new CucumberPropertiesParser()72                .parse(CucumberProperties.fromPropertiesFile())73                .build();74        RuntimeOptions annotationOptions = new CucumberOptionsAnnotationParser()75                .withOptionsProvider(new JUnitCucumberOptionsProvider())76                .parse(clazz)77                .build(propertiesFileOptions);78        RuntimeOptions environmentOptions = new CucumberPropertiesParser()79                .parse(CucumberProperties.fromEnvironment())80                .build(annotationOptions);81        RuntimeOptions runtimeOptions = new CucumberPropertiesParser()82                .parse(CucumberProperties.fromSystemProperties())83                .addDefaultSummaryPrinterIfAbsent()84                .build(environmentOptions);85        RuntimeOptionsBuilder runtimeOptionsBuilder =  new RuntimeOptionsBuilder();86        Collection<String> tagFilters = environmentSpecifiedTags(runtimeOptions.getTagExpressions());87        for(String tagFilter : tagFilters ) {88            runtimeOptionsBuilder.addTagFilter(new LiteralExpression(tagFilter));89        }90        runtimeOptionsBuilder.build(runtimeOptions);91        // Next parse the junit options92        JUnitOptions junitPropertiesFileOptions = new JUnitOptionsParser()93                .parse(CucumberProperties.fromPropertiesFile())94                .build();95        JUnitOptions junitAnnotationOptions = new JUnitOptionsParser()96                .parse(clazz)97                .build(junitPropertiesFileOptions);98        JUnitOptions junitEnvironmentOptions = new JUnitOptionsParser()99                .parse(CucumberProperties.fromEnvironment())100                .build(junitAnnotationOptions);101        JUnitOptions junitOptions = new JUnitOptionsParser()102                .parse(CucumberProperties.fromSystemProperties())103                //.setStrict(runtimeOptions.isStrict())104                .build(junitEnvironmentOptions);105        this.bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);106        setRuntimeOptions(runtimeOptions);107        // Parse the features early. Don't proceed when there are lexer errors108        FeatureParser parser = new FeatureParser(bus::generateId);109        Supplier<ClassLoader> classLoader = ClassLoaders::getDefaultClassLoader;110        FeaturePathFeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(classLoader, runtimeOptions, parser);111        this.features = featureSupplier.get();112        // Create plugins after feature parsing to avoid the creation of empty files on lexer errors.113        this.plugins = new Plugins(new PluginFactory(), runtimeOptions);114        ExitStatus exitStatus = new ExitStatus(runtimeOptions);115        this.plugins.addPlugin(exitStatus);116        Configuration systemConfiguration = Injectors.getInjector().getInstance(Configuration.class);117        // customer change on 20201023118        systemConfiguration.setOutputDirectory(new File(System.getProperty(SerenityCucumberMain.REPORT_PROPERTY_NAME)));119        SerenityReporter reporter = new SerenityReporter(systemConfiguration);120        addSerenityReporterPlugin(plugins,reporter);121        ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(runtimeOptions);122        ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader);123        BackendSupplier backendSupplier = new BackendServiceLoader(clazz::getClassLoader, objectFactorySupplier);124        TypeRegistryConfigurerSupplier typeRegistryConfigurerSupplier = new ScanningTypeRegistryConfigurerSupplier(classLoader, runtimeOptions);125        ThreadLocalRunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier, objectFactorySupplier, typeRegistryConfigurerSupplier);126        this.context = new CucumberExecutionContext(bus, exitStatus, runnerSupplier);127        Predicate<Pickle> filters = new Filters(runtimeOptions);128        Map<Optional<String>, List<Feature>> groupedByName = features.stream()129                .collect(groupingBy(Feature::getName));130        children = features.stream()131                .map(feature -> {132                    Integer uniqueSuffix = uniqueSuffix(groupedByName, feature, Feature::getName);133                    return FeatureRunner.create(feature, uniqueSuffix,filters, runnerSupplier, junitOptions);134                })135                .filter(runner -> !runner.isEmpty())136                .collect(toList());137    }138    private static RuntimeOptions DEFAULT_RUNTIME_OPTIONS;139    public static void setRuntimeOptions(RuntimeOptions runtimeOptions) {140        RUNTIME_OPTIONS.set(runtimeOptions);141        DEFAULT_RUNTIME_OPTIONS = runtimeOptions;142    }143    public static RuntimeOptions currentRuntimeOptions() {144        return (RUNTIME_OPTIONS.get() != null) ? RUNTIME_OPTIONS.get() : DEFAULT_RUNTIME_OPTIONS;145    }146    private static Collection<String> environmentSpecifiedTags(List<?> existingTags) {147        EnvironmentVariables environmentVariables = Injectors.getInjector().getInstance(EnvironmentVariables.class);148        String tagsExpression = ThucydidesSystemProperty.TAGS.from(environmentVariables,"");149        List<String> existingTagsValues = existingTags.stream().map(Object::toString).collect(toList());150        return Splitter.on(",").trimResults().omitEmptyStrings().splitToList(tagsExpression).stream()151                .map(CucumberSerenityRunner::toCucumberTag).filter(t -> !existingTagsValues.contains(t)).collect(toList());152    }153    private static String toCucumberTag(String from) {154        String tag = from.replaceAll(":","=");155        if (tag.startsWith("~@") || tag.startsWith("@")) { return tag; }156        if (tag.startsWith("~")) { return "~@" + tag.substring(1); }157        return "@" + tag;158    }159    public static Runtime createSerenityEnabledRuntime(/*ResourceLoader resourceLoader,*/160            Supplier<ClassLoader> classLoaderSupplier,161            RuntimeOptions runtimeOptions,162            Configuration systemConfiguration) {163        RuntimeOptionsBuilder runtimeOptionsBuilder = new RuntimeOptionsBuilder();164        Collection<String> allTagFilters = environmentSpecifiedTags(runtimeOptions.getTagExpressions());165        for(String tagFilter :  allTagFilters) {166            runtimeOptionsBuilder.addTagFilter(new LiteralExpression(tagFilter));167        }168        runtimeOptionsBuilder.build(runtimeOptions);169        setRuntimeOptions(runtimeOptions);170        EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);171        FeatureParser parser = new FeatureParser(bus::generateId);172        FeaturePathFeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(classLoaderSupplier, runtimeOptions, parser);173        SerenityReporter serenityReporter = new SerenityReporter(systemConfiguration);174        Runtime runtime = Runtime.builder().withClassLoader(classLoaderSupplier).withRuntimeOptions(runtimeOptions).175                withAdditionalPlugins(serenityReporter).176                withEventBus(bus).withFeatureSupplier(featureSupplier).177                build();178        return runtime;179    }180    private static void addSerenityReporterPlugin(Plugins plugins, SerenityReporter plugin)181    {182        for(Plugin currentPlugin : plugins.getPlugins()){183            if (currentPlugin instanceof SerenityReporter) {184                return;185            }186        }187        plugins.addPlugin(plugin);188    }189    @Override190    protected Description describeChild(ParentRunner<?> child) {191        return child.getDescription();192    }193    @Override194    protected void runChild(ParentRunner<?> child, RunNotifier notifier) {195        child.run(notifier);196    }197    @Override198    protected Statement childrenInvoker(RunNotifier notifier) {199        Statement runFeatures = super.childrenInvoker(notifier);200        return new RunCucumber(runFeatures);201    }202    class RunCucumber extends Statement {203        private final Statement runFeatures;204        RunCucumber(Statement runFeatures) {205            this.runFeatures = runFeatures;206        }207        @Override208        public void evaluate() throws Throwable {209            if (multiThreadingAssumed) {210                plugins.setSerialEventBusOnEventListenerPlugins(bus);211            } else {212                plugins.setEventBusOnEventListenerPlugins(bus);213            }214            context.startTestRun();215            features.forEach(context::beforeFeature);216            try {217                runFeatures.evaluate();218            } finally {219                context.finishTestRun();220            }221        }222    }223    @Override224    public void setScheduler(RunnerScheduler scheduler) {225        super.setScheduler(scheduler);226        multiThreadingAssumed = true;227    }228    @Override229    public List<ParentRunner<?>> getChildren() {230        try {231            EnvironmentVariables environmentVariables = Injectors.getInjector().getInstance(EnvironmentVariables.class);232            RuntimeOptions runtimeOptions = currentRuntimeOptions();233            List<Expression> tagFilters = runtimeOptions.getTagExpressions();234            List<URI> featurePaths = runtimeOptions.getFeaturePaths();235            int batchNumber = environmentVariables.getPropertyAsInteger(SERENITY_BATCH_NUMBER, 1);236            int batchCount = environmentVariables.getPropertyAsInteger(SERENITY_BATCH_COUNT, 1);237            int forkNumber = environmentVariables.getPropertyAsInteger(SERENITY_FORK_NUMBER, 1);238            int forkCount = environmentVariables.getPropertyAsInteger(SERENITY_FORK_COUNT, 1);239            if ((batchCount == 1) && (forkCount == 1)) {240                return children;241            } else {242                LOGGER.info("Running slice {} of {} using fork {} of {} from feature paths {}", batchNumber, batchCount, forkNumber, forkCount, featurePaths);243                List<String> tagFiltersAsString =  tagFilters.stream().map(Expression::toString).collect(toList());244                WeightedCucumberScenarios weightedCucumberScenarios = new CucumberSuiteSlicer(featurePaths, TestStatistics.from(environmentVariables, featurePaths))245                        .scenarios(batchNumber, batchCount, forkNumber, forkCount, tagFiltersAsString);246                List<ParentRunner<?>> unfilteredChildren = children;247                AtomicInteger filteredInScenarioCount = new AtomicInteger();248                List<ParentRunner<?>> filteredChildren = unfilteredChildren.stream()249                        .filter(forIncludedFeatures(weightedCucumberScenarios))250                        .map(toPossibleFeatureRunner(weightedCucumberScenarios, filteredInScenarioCount))251                        .filter(Optional::isPresent)252                        .map(Optional::get)253                        .collect(toList());254                if (filteredInScenarioCount.get() != weightedCucumberScenarios.totalScenarioCount()) {255                    LOGGER.warn(256                            "There is a mismatch between the number of scenarios included in this test run ({}) and the expected number of scenarios loaded ({}). This suggests that the scenario filtering is not working correctly or feature file(s) of an unexpected structure are being run",257                            filteredInScenarioCount.get(),258                            weightedCucumberScenarios.scenarios.size());259                }260                LOGGER.info("Running {} of {} features", filteredChildren.size(), unfilteredChildren.size());261                return filteredChildren;262            }263        } catch (Exception e) {264            LOGGER.error("Test failed to start", e);265            throw e;266        }267    }268    private Function<ParentRunner<?>, Optional<ParentRunner<?>>> toPossibleFeatureRunner(WeightedCucumberScenarios weightedCucumberScenarios, AtomicInteger filteredInScenarioCount) {269        return featureRunner -> {270            int initialScenarioCount = featureRunner.getDescription().getChildren().size();271            String featureName = FeatureRunnerExtractors.extractFeatureName(featureRunner);272            try {273                ScenarioFilter filter = weightedCucumberScenarios.createFilterContainingScenariosIn(featureName);274                String featurePath = FeatureRunnerExtractors.featurePathFor(featureRunner);275                featureRunner.filter(filter);276                if (!filter.scenariosIncluded().isEmpty()) {277                    LOGGER.info("{} scenario(s) included for '{}' in {}", filter.scenariosIncluded().size(), featureName, featurePath);278                    filter.scenariosIncluded().forEach(scenario -> {279                        LOGGER.info("Included scenario '{}'", scenario);280                        filteredInScenarioCount.getAndIncrement();281                    });282                }283                if (!filter.scenariosExcluded().isEmpty()) {284                    LOGGER.debug("{} scenario(s) excluded for '{}' in {}", filter.scenariosExcluded().size(), featureName, featurePath);285                    filter.scenariosExcluded().forEach(scenario -> LOGGER.debug("Excluded scenario '{}'", scenario));286                }287                return Optional.of(featureRunner);288            } catch (NoTestsRemainException e) {289                LOGGER.info("Filtered out all {} scenarios for feature '{}'", initialScenarioCount, featureName);290                return Optional.empty();291            }292        };293    }294    private Predicate<ParentRunner<?>> forIncludedFeatures(WeightedCucumberScenarios weightedCucumberScenarios) {295        return featureRunner -> {296            String featureName = FeatureRunnerExtractors.extractFeatureName(featureRunner);297            String featurePath =  PathUtils.getAsFile(FeatureRunnerExtractors.featurePathFor(featureRunner)).getName();298            boolean matches = weightedCucumberScenarios.scenarios.stream().anyMatch(scenario -> featurePath.equals(scenario.featurePath));299            LOGGER.debug("{} in filtering '{}' in {}", matches ? "Including" : "Not including", featureName, featurePath);300            return matches;301        };302    }303}...

Full Screen

Full Screen

Source:CucumberWithSerenity.java Github

copy

Full Screen

...88            } else {89                LOGGER.info("Running slice {} of {} using fork {} of {} from feature paths {}", batchNumber, batchCount, forkNumber, forkCount, featurePaths);90                WeightedCucumberScenarios weightedCucumberScenarios = new CucumberSuiteSlicer(featurePaths, TestStatistics.from(environmentVariables, featurePaths))91                        .scenarios(batchNumber, batchCount, forkNumber, forkCount, tagFilters);92                List<FeatureRunner> unfilteredChildren = super.getChildren();93                AtomicInteger filteredInScenarioCount = new AtomicInteger();94                List<FeatureRunner> filteredChildren = unfilteredChildren.stream()95                        .filter(forIncludedFeatures(weightedCucumberScenarios))96                        .map(toPossibleFeatureRunner(weightedCucumberScenarios, filteredInScenarioCount))97                        .filter(Optional::isPresent)98                        .map(Optional::get)99                        .collect(toList());100                if (filteredInScenarioCount.get() != weightedCucumberScenarios.totalScenarioCount()) {101                    LOGGER.warn(102                            "There is a mismatch between the number of scenarios included in this test run ({}) and the expected number of scenarios loaded ({}). This suggests that the scenario filtering is not working correctly or feature file(s) of an unexpected structure are being run",103                            filteredInScenarioCount.get(),104                            weightedCucumberScenarios.scenarios.size());105                }106                LOGGER.info("Running {} of {} features", filteredChildren.size(), unfilteredChildren.size());107                return filteredChildren;108            }109        } catch (Exception e) {110            LOGGER.error("Test failed to start", e);111            throw e;112        }113    }114    private Function<FeatureRunner, Optional<FeatureRunner>> toPossibleFeatureRunner(WeightedCucumberScenarios weightedCucumberScenarios, AtomicInteger filteredInScenarioCount) {115        return featureRunner -> {116            int initialScenarioCount = featureRunner.getDescription().getChildren().size();117            String featureName = FeatureRunnerExtractors.extractFeatureName(featureRunner);118            try {119                ScenarioFilter filter = weightedCucumberScenarios.createFilterContainingScenariosIn(featureName);120                String featurePath = FeatureRunnerExtractors.featurePathFor(featureRunner);121                featureRunner.filter(filter);122                if (!filter.scenariosIncluded().isEmpty()) {123                    LOGGER.info("{} scenario(s) included for '{}' in {}", filter.scenariosIncluded().size(), featureName, featurePath);124                    filter.scenariosIncluded().forEach(scenario -> {125                        LOGGER.info("Included scenario '{}'", scenario);126                        filteredInScenarioCount.getAndIncrement();127                    });128                }129                if (!filter.scenariosExcluded().isEmpty()) {130                    LOGGER.debug("{} scenario(s) excluded for '{}' in {}", filter.scenariosExcluded().size(), featureName, featurePath);131                    filter.scenariosExcluded().forEach(scenario -> LOGGER.debug("Excluded scenario '{}'", scenario));132                }133                return Optional.of(featureRunner);134            } catch (NoTestsRemainException e) {135                LOGGER.info("Filtered out all {} scenarios for feature '{}'", initialScenarioCount, featureName);136                return Optional.empty();137            }138        };139    }140    private Predicate<FeatureRunner> forIncludedFeatures(WeightedCucumberScenarios weightedCucumberScenarios) {141        return featureRunner -> {142            String featureName = FeatureRunnerExtractors.extractFeatureName(featureRunner);143            String featurePath = Paths.get(FeatureRunnerExtractors.featurePathFor(featureRunner)).getFileName().toString();144            boolean matches = weightedCucumberScenarios.scenarios.stream().anyMatch(scenario -> featurePath.equals(scenario.featurePath));145            LOGGER.debug("{} in filtering '{}' in {}", matches ? "Including" : "Not including", featureName, featurePath);146            return matches;147        };148    }149}...

Full Screen

Full Screen

Source:WeightedCucumberScenarios.java Github

copy

Full Screen

...18import static org.apache.commons.lang3.builder.EqualsBuilder.reflectionEquals;19/**20 * Represents a collection of cucumber scenarios.21 * Can split itself up into a number of smaller WeightedCucumberScenarios.22 * Can return a new WeightedCucumberScenarios that has some scenarios filtered out.23 */24public class WeightedCucumberScenarios {25    private static final Logger LOGGER = LoggerFactory.getLogger(WeightedCucumberScenarios.class);26    public final BigDecimal totalWeighting;27    public final List<WeightedCucumberScenario> scenarios;28    public WeightedCucumberScenarios(List<WeightedCucumberScenario> scenarios) {29        this.scenarios = scenarios;30        this.totalWeighting = scenarios.stream().map(WeightedCucumberScenario::weighting).reduce(ZERO, BigDecimal::add);31    }32    public SliceBuilder slice(int sliceNumber) {33        return new SliceBuilder(sliceNumber, this);34    }35    public List<WeightedCucumberScenarios> sliceInto(int sliceCount) {36        BigDecimal totalWeight = scenarios.stream().map(WeightedCucumberScenario::weighting).reduce(ZERO, BigDecimal::add);37        BigDecimal averageWeightPerSlice = totalWeight.divide(new BigDecimal(sliceCount), 2, RoundingMode.HALF_UP);38        LOGGER.debug("Total weighting for {} scenarios is {}, split across {} slices provides average weighting per slice of {}", scenarios.size(), totalWeight, sliceCount, averageWeightPerSlice);39        List<List<WeightedCucumberScenario>> allScenarios = IntStream.rangeClosed(1, sliceCount).mapToObj(initialiseAs -> new ArrayList<WeightedCucumberScenario>()).collect(toList());40        scenarios.stream()41            .sorted(bySlowestFirst())42            .forEach(scenario -> allScenarios.stream().min(byLowestSumOfDurationFirst()).get().add(scenario));43        return allScenarios.stream().map(WeightedCucumberScenarios::new).collect(toList());44    }45    public ScenarioFilter createFilterContainingScenariosIn(String featureName) {46        LOGGER.debug("Filtering for scenarios in feature {}", featureName);47        List<String> scenarios = this.scenarios.stream()48            .filter(scenario -> {49                boolean matches = scenario.feature.equals(featureName);50                LOGGER.debug("Scenario {} matches {} -> {}", scenario.feature, featureName, matches);51                return matches;52            })53            .map(scenario -> scenario.scenario)54            .collect(toList());55        if (scenarios.isEmpty()) {56            throw new IllegalArgumentException("Can't find feature '" + featureName + "' in this slice");57        }58        return ScenarioFilter.onScenarios(scenarios);59    }60    public WeightedCucumberScenarios filter(Predicate<WeightedCucumberScenario> predicate) {61        return new WeightedCucumberScenarios(scenarios.stream().filter(predicate).collect(toList()));62    }63    @Override64    public int hashCode() {65        return HashCodeBuilder.reflectionHashCode(this);66    }67    @Override68    public boolean equals(Object obj) {69        return reflectionEquals(this, obj);70    }71    @Override72    public String toString() {73        return ToStringBuilder.reflectionToString(this);74    }75    private static Comparator<WeightedCucumberScenario> bySlowestFirst() {...

Full Screen

Full Screen

Source:CucumberScenarioLoader.java Github

copy

Full Screen

...44        return cucumberFeature -> {45            try {46                return (cucumberFeature.getGherkinFeature().getFeature() == null) ? Collections.emptyList() : cucumberFeature.getGherkinFeature().getFeature().getChildren()47                    .stream()48                    .filter(child -> asList(ScenarioOutline.class, Scenario.class).contains(child.getClass()))49                    .map(scenarioDefinition -> new WeightedCucumberScenario(50                        PathUtils.getAsFile(cucumberFeature.getUri()).getName(),51                        cucumberFeature.getGherkinFeature().getFeature().getName(),52                        scenarioDefinition.getName(),53                        scenarioWeightFor(cucumberFeature, scenarioDefinition),54                        tagsFor(cucumberFeature, scenarioDefinition),55                        scenarioCountFor(scenarioDefinition)))56                    .collect(toList());57            } catch (Exception e) {58                throw new IllegalStateException(String.format("Could not extract scenarios from %s", cucumberFeature.getUri()), e);59            }60        };61    }62    private int scenarioCountFor(ScenarioDefinition scenarioDefinition) {...

Full Screen

Full Screen

Source:CucumberSuiteSlicer.java Github

copy

Full Screen

...12        this.statistics = statistics;13    }14    public WeightedCucumberScenarios scenarios(int batchNumber, int batchCount, int forkNumber, int forkCount, List<String> tagFilters) {15        return new CucumberScenarioLoader(featurePaths, statistics).load()16            .filter(forSuppliedTags(tagFilters))17            .slice(batchNumber).of(batchCount).slice(forkNumber).of(forkCount);18    }19    private Predicate<WeightedCucumberScenario> forSuppliedTags(List<String> tagFilters) {20        return cucumberScenario -> TagParser.parseFromTagFilters(tagFilters).evaluate(newArrayList(cucumberScenario.tags));21    }22}...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful