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

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

Run Serenity Cucumber automation tests on LambdaTest cloud grid

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

copy
1package net.serenitybdd.cucumber.util;
2
3import net.thucydides.core.model.TakeScreenshots;
4import org.junit.Test;
5
6import static org.assertj.core.api.Assertions.assertThat;
7
8public class StepDefinitionAnnotationReaderTest {
9
10    @Test
11    public void should_read_annotations_from_a_step_definition_method_name() {
12        assertThat(
13                StepDefinitionAnnotationReader
14                        .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAScreenshotAnnotation()")
15                        .getScreenshotPreferences()
16        ).isEqualTo(TakeScreenshots.DISABLED);
17    }
18
19    @Test
20    public void should_read_annotations_from_a_parameterised_step_definition_method_name() {
21        assertThat(
22                StepDefinitionAnnotationReader
23                        .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAParameter(java.lang.String)")
24                        .getScreenshotPreferences()
25        ).isEqualTo(TakeScreenshots.DISABLED);
26    }
27
28    @Test
29    public void screenshot_preference_is_undefined_if_no_annotation_is_present() {
30        assertThat(
31                StepDefinitionAnnotationReader
32                        .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithNoScreenshotAnnotation()")
33                        .getScreenshotPreferences()
34        ).isEqualTo(TakeScreenshots.UNDEFINED);
35    }
36    @Test
37    public void screenshot_preference_is_before_and_after_each_step_by_default_if_no_annotation_is_present() {
38        assertThat(
39                StepDefinitionAnnotationReader
40                        .forStepDefinition("net.serenitybdd.cucumber.util.SampleStepDefinitions.aStepDefinitionWithAScreenshotAnnotationWithNoAttribute()")
41                        .getScreenshotPreferences()
42        ).isEqualTo(TakeScreenshots.BEFORE_AND_AFTER_EACH_STEP);
43    }
44}
45
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

...Most popular Stackoverflow questions on StepDefinitionAnnotationReader

    No relevant questions found for this class 😞

Most used methods in StepDefinitionAnnotationReader

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free
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)