How to use StepDefinitionAnnotationReader class of net.serenitybdd.cucumber.util package

Best Serenity Cucumber code snippet using net.serenitybdd.cucumber.util.StepDefinitionAnnotationReader

Source:SerenityReporter.java Github

copy

Full Screen

...14import net.serenitybdd.core.SerenityReports;15import net.serenitybdd.cucumber.CucumberWithSerenity;16import net.serenitybdd.cucumber.formatting.ScenarioOutlineDescription;17import net.serenitybdd.cucumber.util.PathUtils;18import net.serenitybdd.cucumber.util.StepDefinitionAnnotationReader;19import net.thucydides.core.guice.Injectors;20import net.thucydides.core.model.DataTable;21import net.thucydides.core.model.TestStep;22import net.thucydides.core.model.*;23import net.thucydides.core.model.screenshots.StepDefinitionAnnotations;24import net.thucydides.core.model.stacktrace.RootCauseAnalyzer;25import net.thucydides.core.reports.ReportService;26import net.thucydides.core.steps.*;27import net.thucydides.core.util.Inflector;28import net.thucydides.core.webdriver.Configuration;29import net.thucydides.core.webdriver.ThucydidesWebDriverSupport;30import org.jetbrains.annotations.NotNull;31import org.junit.internal.AssumptionViolatedException;32import org.slf4j.Logger;33import org.slf4j.LoggerFactory;34import java.io.File;35import java.net.URI;36import java.util.*;37import java.util.stream.Collectors;38import static io.cucumber.core.plugin.TaggedScenario.*;39import static java.util.stream.Collectors.toList;40import static org.apache.commons.lang3.StringUtils.isEmpty;41import static org.apache.commons.lang3.StringUtils.isNotEmpty;42/**43 * Cucumber Formatter for Serenity.44 *45 * @author L.Carausu (liviu.carausu@gmail.com)46 */47public class SerenityReporter implements Plugin, ConcurrentEventListener {48 private static final String OPEN_PARAM_CHAR = "\uff5f";49 private static final String CLOSE_PARAM_CHAR = "\uff60";50 private static final String SCENARIO_OUTLINE_NOT_KNOWN_YET = "";51 private Configuration systemConfiguration;52 private final List<BaseStepListener> baseStepListeners;53 private final static String FEATURES_ROOT_PATH = "features";54 private FeatureFileLoader featureLoader = new FeatureFileLoader();55 private LineFilters lineFilters;56 private List<Tag> scenarioTags;57 private static final Logger LOGGER = LoggerFactory.getLogger(SerenityReporter.class);58 private ManualScenarioChecker manualScenarioDateChecker;59 private ThreadLocal<ScenarioContext> localContext = ThreadLocal.withInitial(ScenarioContext::new);60 private ScenarioContext getContext() {61 return localContext.get();62 }63 /**64 * Constructor automatically called by cucumber when class is specified as plugin65 * in @CucumberOptions.66 */67 public SerenityReporter() {68 this.systemConfiguration = Injectors.getInjector().getInstance(Configuration.class);69 this.manualScenarioDateChecker = new ManualScenarioChecker(systemConfiguration.getEnvironmentVariables());70 baseStepListeners = Collections.synchronizedList(new ArrayList<>());71 lineFilters = LineFilters.forCurrentContext();72 }73 public SerenityReporter(Configuration systemConfiguration) {74 this.systemConfiguration = systemConfiguration;75 this.manualScenarioDateChecker = new ManualScenarioChecker(systemConfiguration.getEnvironmentVariables());76 baseStepListeners = Collections.synchronizedList(new ArrayList<>());77 lineFilters = LineFilters.forCurrentContext();78 }79 private FeaturePathFormatter featurePathFormatter = new FeaturePathFormatter();80 private StepEventBus getStepEventBus(URI featurePath) {81 URI prefixedPath = featurePathFormatter.featurePathWithPrefixIfNecessary(featurePath);82 return StepEventBus.eventBusFor(prefixedPath);83 }84 private void setStepEventBus(URI featurePath) {85 URI prefixedPath = featurePathFormatter.featurePathWithPrefixIfNecessary(featurePath);86 StepEventBus.setCurrentBusToEventBusFor(prefixedPath);87 }88 private void initialiseListenersFor(URI featurePath) {89 if (getStepEventBus(featurePath).isBaseStepListenerRegistered()) {90 return;91 }92 SerenityListeners listeners = new SerenityListeners(getStepEventBus(featurePath), systemConfiguration);93 baseStepListeners.add(listeners.getBaseStepListener());94 }95 private EventHandler<TestSourceRead> testSourceReadHandler = this::handleTestSourceRead;96 private EventHandler<TestCaseStarted> caseStartedHandler = this::handleTestCaseStarted;97 private EventHandler<TestCaseFinished> caseFinishedHandler = this::handleTestCaseFinished;98 private EventHandler<TestStepStarted> stepStartedHandler = this::handleTestStepStarted;99 private EventHandler<TestStepFinished> stepFinishedHandler = this::handleTestStepFinished;100 private EventHandler<TestRunStarted> runStartedHandler = this::handleTestRunStarted;101 private EventHandler<TestRunFinished> runFinishedHandler = this::handleTestRunFinished;102 private EventHandler<WriteEvent> writeEventHandler = this::handleWrite;103 private void handleTestRunStarted(TestRunStarted event) {104 }105 @Override106 public void setEventPublisher(EventPublisher publisher) {107 publisher.registerHandlerFor(TestSourceRead.class, testSourceReadHandler);108 publisher.registerHandlerFor(TestRunStarted.class, runStartedHandler);109 publisher.registerHandlerFor(TestRunFinished.class, runFinishedHandler);110 publisher.registerHandlerFor(TestCaseStarted.class, caseStartedHandler);111 publisher.registerHandlerFor(TestCaseFinished.class, caseFinishedHandler);112 publisher.registerHandlerFor(TestStepStarted.class, stepStartedHandler);113 publisher.registerHandlerFor(TestStepFinished.class, stepFinishedHandler);114 publisher.registerHandlerFor(WriteEvent.class, writeEventHandler);115 }116 private void handleTestSourceRead(TestSourceRead event) {117 featureLoader.addTestSourceReadEvent(event);118 URI featurePath = event.getUri();119 featureFrom(featurePath).ifPresent(120 feature -> {121 getContext().setFeatureTags(feature.getTags());122 resetEventBusFor(featurePath);123 initialiseListenersFor(featurePath);124 configureDriver(feature, featurePath);125 Story userStory = userStoryFrom(feature, relativeUriFrom(event.getUri()));126 getStepEventBus(event.getUri()).testSuiteStarted(userStory);127 }128 );129 }130 private void resetEventBusFor(URI featurePath) {131 StepEventBus.clearEventBusFor(featurePath);132 }133 private String relativeUriFrom(URI fullPathUri) {134 String pathURIAsString = fullPathUri.toString();135 String featuresRoot = File.separatorChar + FEATURES_ROOT_PATH + File.separatorChar;136 if (pathURIAsString.contains(featuresRoot)) {137 return pathURIAsString.substring(pathURIAsString.lastIndexOf(featuresRoot) + FEATURES_ROOT_PATH.length() + 2);138 } else {139 return pathURIAsString;140 }141 }142 private Optional<Feature> featureFrom(URI featureFileUri) {143 LOGGER.info("Running feature from " + featureFileUri.toString());144 String featuresRoot = File.separatorChar + FEATURES_ROOT_PATH + File.separatorChar;145 if(!featureFileUri.toString().contains(featuresRoot)) {146 LOGGER.warn("Feature from " + featureFileUri + " is not under the 'features' directory. Requirements report will not be correctly generated!");147 }148 String defaultFeatureId = PathUtils.getAsFile(featureFileUri).getName().replace(".feature", "");149 String defaultFeatureName = Inflector.getInstance().humanize(defaultFeatureId);150 parseGherkinIn(featureFileUri);151 if (isEmpty(featureLoader.getFeatureName(featureFileUri))) {152 return Optional.empty();153 }154 Feature feature = featureLoader.getFeature(featureFileUri);155 if (feature.getName().isEmpty()) {156 feature = featureLoader.featureWithDefaultName(feature, defaultFeatureName);157 }158 return Optional.of(feature);159 }160 private void parseGherkinIn(URI featureFileUri) {161 try {162 featureLoader.getFeature(featureFileUri);163 } catch (Throwable ignoreParsingErrors) {164 LOGGER.warn("Could not parse the Gherkin in feature file " + featureFileUri + ": file ignored");165 }166 }167 private Story userStoryFrom(Feature feature, String featureFileUriString) {168 Story userStory = Story.withIdAndPath(TestSourcesModel.convertToId(feature.getName()), feature.getName(), featureFileUriString).asFeature();169 if (!isEmpty(feature.getDescription())) {170 userStory = userStory.withNarrative(feature.getDescription());171 }172 return userStory;173 }174 private void handleTestCaseStarted(TestCaseStarted event) {175 URI featurePath = event.getTestCase().getUri();176 getContext().currentFeaturePathIs(featurePath);177 setStepEventBus(featurePath);178 String scenarioName = event.getTestCase().getName();179 TestSourcesModel.AstNode astNode = featureLoader.getAstNode(getContext().currentFeaturePath(), event.getTestCase().getLine());180 Optional<Feature> currentFeature = featureFrom(featurePath);181 if ((astNode != null) && currentFeature.isPresent()) {182 getContext().setCurrentScenarioDefinitionFrom(astNode);183 //the sources are read in parallel, global current feature cannot be used184 String scenarioId = scenarioIdFrom(currentFeature.get().getName(), TestSourcesModel.convertToId(getContext().currentScenarioDefinition.getName()));185 boolean newScenario = !scenarioId.equals(getContext().getCurrentScenario());186 if (newScenario) {187 configureDriver(currentFeature.get(), getContext().currentFeaturePath());188 if (getContext().isAScenarioOutline()) {189 getContext().startNewExample();190 handleExamples(currentFeature.get(),191 getContext().currentScenarioOutline().getTags(),192 getContext().currentScenarioOutline().getName(),193 getContext().currentScenarioOutline().getExamples());194 }195 startOfScenarioLifeCycle(currentFeature.get(), scenarioName, getContext().currentScenarioDefinition, event.getTestCase().getLine());196 getContext().currentScenario = scenarioIdFrom(currentFeature.get().getName(), TestSourcesModel.convertToId(getContext().currentScenarioDefinition.getName()));197 } else {198 if (getContext().isAScenarioOutline()) {199 startExample(event.getTestCase().getLine());200 }201 }202 Background background = TestSourcesModel.getBackgroundForTestCase(astNode);203 if (background != null) {204 handleBackground(background);205 }206 }207 }208 private void handleTestCaseFinished(TestCaseFinished event) {209 if (getContext().examplesAreRunning()) {210 handleResult(event.getResult());211 finishExample();212 }213 if (Status.FAILED.equals(event.getResult()) && noAnnotatedResultIdDefinedFor(event)) {214 getStepEventBus(event.getTestCase().getUri()).testFailed(event.getResult().getError());215 } else {216 getStepEventBus(event.getTestCase().getUri()).testFinished(getContext().examplesAreRunning());217 }218 getContext().clearStepQueue();219 }220 private boolean noAnnotatedResultIdDefinedFor(TestCaseFinished event) {221 BaseStepListener baseStepListener = getStepEventBus(event.getTestCase().getUri()).getBaseStepListener();222 return (baseStepListener.getTestOutcomes().isEmpty() || (latestOf(baseStepListener.getTestOutcomes()).getAnnotatedResult() == null));223 }224 private TestOutcome latestOf(List<TestOutcome> testOutcomes) {225 return testOutcomes.get(testOutcomes.size() - 1);226 }227 private List<String> createCellList(PickleRow row) {228 List<String> cells = new ArrayList<>();229 for (PickleCell cell : row.getCells()) {230 cells.add(cell.getValue());231 }232 return cells;233 }234 private void handleTestStepStarted(TestStepStarted event) {235 StepDefinitionAnnotations.setScreenshotPreferencesTo(236 StepDefinitionAnnotationReader237 .withScreenshotLevel((TakeScreenshots) systemConfiguration.getScreenshotLevel()238 .orElse(TakeScreenshots.UNDEFINED))239 .forStepDefinition(event.getTestStep().getCodeLocation())240 .getScreenshotPreferences());241 if (!(event.getTestStep() instanceof HookTestStep)) {242 if (event.getTestStep() instanceof PickleStepTestStep) {243 PickleStepTestStep pickleTestStep = (PickleStepTestStep) event.getTestStep();244 TestSourcesModel.AstNode astNode = featureLoader.getAstNode(getContext().currentFeaturePath(), pickleTestStep.getStepLine());245 if (astNode != null) {246 io.cucumber.core.internal.gherkin.ast.Step step = (io.cucumber.core.internal.gherkin.ast.Step) astNode.node;247 if (!getContext().isAddingScenarioOutlineSteps()) {248 getContext().queueStep(step);249 getContext().queueTestStep(event.getTestStep());250 }...

Full Screen

Full Screen

Source:StepDefinitionAnnotationReader.java Github

copy

Full Screen

...11import java.util.Optional;12import java.util.regex.Matcher;13import java.util.regex.Pattern;14import static java.util.Arrays.stream;15public class StepDefinitionAnnotationReader {16 private String stepDefinitionPath;17 private TakeScreenshots screenshotDefaultLevel = TakeScreenshots.UNDEFINED;18 private static final Logger LOGGER = LoggerFactory.getLogger(StepDefinitionAnnotationReader.class);19 public StepDefinitionAnnotationReader(String stepDefinitionPath) {20 this.stepDefinitionPath = stepDefinitionPath;21 }22 public StepDefinitionAnnotationReader(String stepDefinitionPath, TakeScreenshots screenshotDefaultLevel) {23 this.screenshotDefaultLevel = screenshotDefaultLevel;24 this.stepDefinitionPath = stepDefinitionPath;25 }26 public static StepDefinitionAnnotationReader forStepDefinition(String stepDefinitionPath) {27 return new StepDefinitionAnnotationReader(stepDefinitionPath);28 }29 public static Builder withScreenshotLevel(TakeScreenshots screenshotLevel) {30 return new Builder(screenshotLevel);31 }32 public TakeScreenshots getScreenshotPreferences() {33 if (stepDefinitionPath == null) {34 return TakeScreenshots.UNDEFINED;35 }36 List<Annotation> stepDefinitionAnnotations = annotationsIn(className(), methodName());37 return stepDefinitionAnnotations.stream()38 .filter(annotation -> annotation instanceof Screenshots)39 .map(annotation -> asEnum((Screenshots) annotation))40 .findFirst()41 .orElse(screenshotDefaultLevel);42 }43 private TakeScreenshots asEnum(Screenshots screenshotAnnotation) {44 if (screenshotAnnotation.disabled()) {45 return TakeScreenshots.DISABLED;46 } else if (screenshotAnnotation.afterEachStep()) {47 return TakeScreenshots.AFTER_EACH_STEP;48 } else if (screenshotAnnotation.beforeAndAfterEachStep()) {49 return TakeScreenshots.BEFORE_AND_AFTER_EACH_STEP;50 } else if (screenshotAnnotation.forEachAction()) {51 return TakeScreenshots.FOR_EACH_ACTION;52 } else if (screenshotAnnotation.onlyOnFailures()) {53 return TakeScreenshots.FOR_FAILURES;54 } else {55 return TakeScreenshots.UNDEFINED;56 }57 }58 private String className() {59 Matcher matcher = Pattern.compile("^(\\w*\\s)").matcher(stepDefinitionPath);60 if (matcher.lookingAt()) {61 stepDefinitionPath = matcher.replaceFirst("");62 }63 int lastOpeningParentheses;64 if (stepDefinitionPath.contains("(")) {65 lastOpeningParentheses = stepDefinitionPath.lastIndexOf("(");66 } else {67 lastOpeningParentheses = stepDefinitionPath.toCharArray().length;68 }69 String qualifiedMethodName = stepDefinitionPath.substring(0, lastOpeningParentheses);70 int endOfClassName = qualifiedMethodName.lastIndexOf(".");71 return stepDefinitionPath.substring(0, endOfClassName);72 }73 private String methodName() {74 int lastOpeningParentheses;75 if (stepDefinitionPath.contains("(")) {76 lastOpeningParentheses = stepDefinitionPath.lastIndexOf("(");77 } else {78 lastOpeningParentheses = stepDefinitionPath.toCharArray().length;79 }80 String qualifiedMethodName = stepDefinitionPath.substring(0, lastOpeningParentheses);81 int startOfMethodName = qualifiedMethodName.lastIndexOf(".") + 1;82 return stepDefinitionPath.substring(startOfMethodName, lastOpeningParentheses);83 }84 private List<Annotation> annotationsIn(String className, String methodName) {85 try {86 Optional<Method> matchingMethod87 = stream(Class.forName(className).getMethods())88 .filter(method -> method.getName().equals(methodName))89 .findFirst();90 return matchingMethod91 .map(method -> Arrays.asList(method.getAnnotations()))92 .orElseGet(ArrayList::new);93 } catch (ClassNotFoundException e) {94 LOGGER.warn("Could not analyse step definition method " + className + "." + methodName);95 }96 return new ArrayList<>();97 }98 public static class Builder {99 private final TakeScreenshots screenshotLevel;100 public Builder(TakeScreenshots screenshotLevel) {101 this.screenshotLevel = screenshotLevel;102 }103 public StepDefinitionAnnotationReader forStepDefinition(String stepDefinitionPath) {104 return new StepDefinitionAnnotationReader(stepDefinitionPath, screenshotLevel);105 }106 }107}...

Full Screen

Full Screen

Source:StepDefinitionAnnotationReaderTest.java Github

copy

Full Screen

1package net.serenitybdd.cucumber.util;2import net.thucydides.core.model.TakeScreenshots;3import org.junit.Test;4import static org.assertj.core.api.Assertions.assertThat;5public class StepDefinitionAnnotationReaderTest {6 @Test7 public void should_read_annotations_from_a_step_definition_method_name() {8 assertThat(9 StepDefinitionAnnotationReader10 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAScreenshotAnnotation()")11 .getScreenshotPreferences()12 ).isEqualTo(TakeScreenshots.DISABLED);13 }14 @Test15 public void should_read_annotations_from_a_parameterised_step_definition_method_name() {16 assertThat(17 StepDefinitionAnnotationReader18 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAParameter(java.lang.String)")19 .getScreenshotPreferences()20 ).isEqualTo(TakeScreenshots.DISABLED);21 }22 @Test23 public void screenshot_preference_is_undefined_if_no_annotation_is_present() {24 assertThat(25 StepDefinitionAnnotationReader26 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithNoScreenshotAnnotation()")27 .getScreenshotPreferences()28 ).isEqualTo(TakeScreenshots.UNDEFINED);29 }30 @Test31 public void screenshot_preference_is_before_and_after_each_step_by_default_if_no_annotation_is_present() {32 assertThat(33 StepDefinitionAnnotationReader34 .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAScreenshotAnnotationWithNoAttribute()")35 .getScreenshotPreferences()36 ).isEqualTo(TakeScreenshots.BEFORE_AND_AFTER_EACH_STEP);37 }38}...

Full Screen

Full Screen

StepDefinitionAnnotationReader

Using AI Code Generation

copy

Full Screen

1import net.serenitybdd.cucumber.util.StepDefinitionAnnotationReader2import net.serenitybdd.cucumber.util.StepDefinitionAnnotation3import net.thucydides.core.annotations.Step4def annotations = StepDefinitionAnnotationReader.getStepDefinitionAnnotations()5for (annotation in annotations) {6 def annotationValue = annotation.getAnnotation().value()7 for (value in annotationValue) {8 annotationValueList.add(value)9 }10 annotationsList.add(annotationValueList)11}

Full Screen

Full Screen

StepDefinitionAnnotationReader

Using AI Code Generation

copy

Full Screen

1StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();2List<StepDefinitionAnnotation> annotations = reader.readAnnotations();3List<StepDefinitionAnnotation> annotationsForClass = reader.readAnnotationsForClass("net.serenitybdd.cucumber.integration.steps.CalculatorSteps");4List<StepDefinitionAnnotation> annotationsForMethod = reader.readAnnotationsForMethod("net.serenitybdd.cucumber.integration.steps.CalculatorSteps", "I_have_entered_$_into_the_calculator");5StepDefinitionAnnotation annotation = new StepDefinitionAnnotation();6String value = annotation.getValue();7List<Map<String, String>> examples = annotation.getExamples();8List<String> tags = annotation.getTags();9List<String> stepDefinitions = annotation.getStepDefinitions();10List<StepDefinition> stepDefinitions = annotation.getStepDefinitions();11List<StepDefinition> stepDefinitions = annotation.getStepDefinitions();12StepDefinition stepDefinition = new StepDefinition();13String value = stepDefinition.getValue();14List<Map<String, String>> examples = stepDefinition.getExamples();15List<String> tags = stepDefinition.getTags();16List<String> stepDefinitions = stepDefinition.getStepDefinitions();17List<StepDefinition> stepDefinitions = stepDefinition.getStepDefinitions();18List<StepDefinition> stepDefinitions = stepDefinition.getStepDefinitions();19StepDefinitionAnnotationReader reader = new StepDefinitionAnnotationReader();

Full Screen

Full Screen

StepDefinitionAnnotationReader

Using AI Code Generation

copy

Full Screen

1package net.serenitybdd.cucumber.util;2import java.lang.annotation.Annotation;3import java.lang.reflect.Method;4import java.util.ArrayList;5import java.util.Arrays;6import java.util.List;7public class StepDefinitionAnnotationReader {8 public static List<Annotation> getStepDefinitionAnnotations(Method method) {9 List<Annotation> annotations = new ArrayList<Annotation>();10 List<Class<? extends Annotation>> annotationTypes = Arrays.asList(CucumberWithSerenity.class, Given.class, When.class, Then.class, And.class, But.class);11 for (Annotation annotation : method.getAnnotations()) {12 if (annotationTypes.contains(annotation.annotationType())) {13 annotations.add(annotation);14 }15 }16 return annotations;17 }18}19package net.serenitybdd.cucumber.util;20import java.lang.annotation.Annotation;21import java.lang.reflect.Method;22import java.util.ArrayList;23import java.util.Arrays;24import java.util.List;25public class StepDefinitionAnnotationReader {26 public static List<Annotation> getStepDefinitionAnnotations(Method method) {27 List<Annotation> annotations = new ArrayList<Annotation>();28 List<Class<? extends Annotation>> annotationTypes = Arrays.asList(CucumberWithSerenity.class, Given.class, When.class, Then.class, And.class, But.class);29 for (Annotation annotation : method.getAnnotations()) {30 if (annotationTypes.contains(annotation.annotationType())) {31 annotations.add(annotation);32 }33 }34 return annotations;35 }36}37package net.serenitybdd.cucumber.util;38import java.lang.annotation.Annotation;39import java.lang.reflect.Method;40import java.util.ArrayList;41import java.util.Arrays;42import java.util.List;43public class StepDefinitionAnnotationReader {44 public static List<Annotation> getStepDefinitionAnnotations(Method method) {45 List<Annotation> annotations = new ArrayList<Annotation>();

Full Screen

Full Screen

StepDefinitionAnnotationReader

Using AI Code Generation

copy

Full Screen

1StepDefinitionAnnotationReader stepDefinitionAnnotationReader = new StepDefinitionAnnotationReader("classpath:features");2List<StepDefinitionAnnotation> stepDefinitionAnnotations = stepDefinitionAnnotationReader.getStepDefinitionAnnotations();3List<StepDefinitionAnnotation> stepDefinitionAnnotationsForStepDefinition = stepDefinitionAnnotationReader.getStepDefinitionAnnotationsForStepDefinition("I have (\\d+) cukes in my belly");4List<StepDefinitionAnnotation> stepDefinitionAnnotationsForStepDefinitionPattern = stepDefinitionAnnotationReader.getStepDefinitionAnnotationsForStepDefinitionPattern("I have (\\d+) cukes in my belly");5List<StepDefinitionAnnotation> stepDefinitionAnnotationsForStepDefinitionPattern = stepDefinitionAnnotationReader.getStepDefinitionAnnotationsForStepDefinitionPattern("I have (\\d+) cukes in my belly");6package net.serenitybdd.cucumber.util;7import java.io.IOException;8import java.util.ArrayList;9import java.util.Collections;10import java.util.List;11import java.util.stream.Collectors;12import org.apache.commons.lang3.StringUtils;13import org.reflections.Reflections;14import org.reflections.scanners.MethodAnnotationsScanner;15import org.reflections.scanners.TypeAnnotationsScanner;16import org.reflections.util.ClasspathHelper;17import org.reflections.util.ConfigurationBuilder;18import net.serenitybdd.cucumber.annotations.StepDefinitionAnnotation;19import net.thucydides.core.util.EnvironmentVariables;20public class StepDefinitionAnnotationReader {21 private final Reflections reflections;22 private final List<StepDefinitionAnnotation> stepDefinitionAnnotations;23 public StepDefinitionAnnotationReader(EnvironmentVariables environmentVariables) {24 this.reflections = new Reflections(new ConfigurationBuilder()25 .setUrls(ClasspathHelper.forPackage(environmentVariables.getProperty("serenity.package")))26 .setScanners(new MethodAnnotationsScanner(), new TypeAnnotationsScanner()));27 this.stepDefinitionAnnotations = getStepDefinitionAnnotations();28 }29 public StepDefinitionAnnotationReader(String classpath) {30 this.reflections = new Reflections(new ConfigurationBuilder()31 .setUrls(ClasspathHelper.forPackage(classpath))32 .setScanners(new MethodAnnotationsScanner(),

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 StepDefinitionAnnotationReader

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