How to use findStoriesCalled method of net.serenitybdd.jbehave.SerenityStories class

Best Serenity jBehave code snippet using net.serenitybdd.jbehave.SerenityStories.findStoriesCalled

Source:WhenRunningASelectionOfJBehaveStories.java Github

copy

Full Screen

...15 public AStorySample() {16 super();17 }18 protected AStorySample(String storyName) {19 findStoriesCalled(storyName);20 }21 }22 @Test23 public void all_stories_on_the_classpath_should_be_run_by_default() {24 // Given25 SerenityStories first = new SerenityStorySampleForFistLevel();26 SerenityStories second = new SerenityStorySampleForSecondLevel();27 // Then28 assertThat(first.getRootPackage(), equalTo(second.getRootPackage()));29 assertThat(first.getStoryPath(), equalTo(second.getStoryPath()));30 assertThat(first.stepsFactory().createCandidateSteps().containsAll(second.stepsFactory().createCandidateSteps()), is(true));31 assertThat(first.getStoryPath(), is("**/*.story"));32 }33 final static class StoriesInTheSubsetFolderSample extends SerenityStories {34 StoriesInTheSubsetFolderSample(EnvironmentVariables environmentVariables) {35 super(environmentVariables);36 findStoriesIn("stories/subset");37 }38 }39 @Test40 public void a_subset_of_the_stories_can_be_run_individually() {41 // Given42 SerenityStories stories = new StoriesInTheSubsetFolderSample(environmentVariables);43 // When44 run(stories);45 // Then46 List<TestOutcome> outcomes = loadTestOutcomes();47 assertThat(outcomes.size(), is(5));48 }49 @Test50 public void stories_with_a_matching_name_can_be_run() {51 // Given52 SerenityStories stories = newStory("*PassingBehavior.story");53 // When54 run(stories);55 // Then56 List<TestOutcome> outcomes = loadTestOutcomes();57 assertThat(outcomes.size(), is(6));58 }59 @Test60 public void environment_specific_stories_should_be_executed_if_the_corresponding_environment_variable_is_set() {61 // Given62 systemConfiguration.getEnvironmentVariables().setProperty("metafilter", "+environment uat");63 SerenityStories uatStory = new ASampleBehaviorForUatOnly(systemConfiguration);64// uatStory.setSystemConfiguration(systemConfiguration);65 uatStory.setEnvironmentVariables(environmentVariables);66 // When67 run(uatStory);68 // Then69 List<TestOutcome> outcomes = loadTestOutcomes();70 assertThat(outcomes.size(), is(1));71 assertThat(outcomes.get(0).getResult(), is(TestResult.SUCCESS));72 }73 @Test74 public void should_be_possible_to_define_multiple_metafilters() {75 // Given76 systemConfiguration.getEnvironmentVariables().setProperty("metafilter", "+environment uat, +speed fast");77 SerenityStories allStories = new SerenityStories(systemConfiguration);78 allStories.setSystemConfiguration(systemConfiguration);79 allStories.setEnvironmentVariables(environmentVariables);80 // When81 run(allStories);82 // Then83 List<TestOutcome> outcomes = loadTestOutcomes();84 assertThat(excludeSkippedAndIgnored(outcomes).size(), is(4));85 }86 @Test87 public void should_be_possible_to_define_metafilters_in_annotations() {88 // Given89 SerenityStories allStories = new WithAnAnnotatedMetafilter();90 allStories.setSystemConfiguration(systemConfiguration);91 allStories.setEnvironmentVariables(environmentVariables);92 // When93 run(allStories);94 // Then95 List<TestOutcome> outcomes = loadTestOutcomes();96 assertThat(excludeSkippedAndIgnored(outcomes).size(), is(2));97 }98 @Test99 public void system_property_metafilters_should_override_annotations() {100 // Given101 systemConfiguration.getEnvironmentVariables().setProperty("metafilter", "+environment uat, +speed fast");102 SerenityStories allStories = new WithAnAnnotatedMetafilter();103 allStories.setSystemConfiguration(systemConfiguration);104 allStories.setEnvironmentVariables(environmentVariables);105 // When106 run(allStories);107 // Then108 List<TestOutcome> outcomes = loadTestOutcomes();109 assertThat(excludeSkippedAndIgnored(outcomes).size(), is(4));110 }111 @Test112 public void should_be_possible_to_define_groovy_metafilters() {113 // Given114 systemConfiguration.getEnvironmentVariables().setProperty("webdriver.driver", "htmlunit");115 systemConfiguration.getEnvironmentVariables().setProperty("metafilter", "groovy:('a'=='b')");116 SerenityStories allStories = new SerenityStories(systemConfiguration);117 allStories.setSystemConfiguration(systemConfiguration);118 allStories.setEnvironmentVariables(environmentVariables);119 // When120 run(allStories);121 // Then122 List<TestOutcome> outcomes = loadTestOutcomes();123 assertThat(excludeSkippedAndIgnored(outcomes).size(), is(0));124 }125 @Test126 public void environment_specific_stories_should_not_be_executed_if_a_filter_excludes_it() {127 systemConfiguration.getEnvironmentVariables().setProperty("metafilter", "-environment uat");128 // Given129 SerenityStories uatStory = new ASampleBehaviorForUatOnly(systemConfiguration);130 // When131 run(uatStory);132 // Then133 List<TestOutcome> outcomes = loadTestOutcomes();134 assertThat(outcomes.size(), is(0));135 }136 final class AnotherStorySample extends SerenityStories {137 public AnotherStorySample() {138 super(environmentVariables);139 findStoriesCalled("stories/samples/*Behavior.story");140 }141 }142 @Test143 public void test_should_run_stories_in_a_specified_place() {144 // Given145 SerenityStories story = new AnotherStorySample();146 // When147 run(story);148 // Then149 List<TestOutcome> outcomes = loadTestOutcomes();150 assertThat(outcomes.size(), is(3));151 }152 private List<? extends TestOutcome> excludeSkippedAndIgnored(final List<TestOutcome> source) {153 return TestOutcomes.of(source.stream()...

Full Screen

Full Screen

Source:WhenRunningJBehaveFixtures.java Github

copy

Full Screen

...12 public AStorySample() {13 super();14 }15 protected AStorySample(String storyName) {16 findStoriesCalled(storyName);17 }18 }19 @Test20 public void should_run_before_story_methods() {21 // Given22 SerenityStories stories = new AStorySample("aPassingBehavior.story");23 stories.setSystemConfiguration(systemConfiguration);24 FixtureMethods.beforeStoryCalledCount = 0;25 // When26 run(stories);27 // Then28 assertThat(FixtureMethods.beforeStoryCalledCount, is(1));29 }30 @Test31 public void should_run_before_scenario_methods() {32 // Given33 SerenityStories stories = new AStorySample("aPassingBehaviorWithSeveralScenarios.story");34 stories.setSystemConfiguration(systemConfiguration);35 FixtureMethods.beforeScenarioCalledCount = 0;36 // When37 run(stories);38 // Then39 assertThat(FixtureMethods.beforeScenarioCalledCount, is(2));40 }41 @Test42 public void should_run_before_scenario_methods_for_lots_of_stories() {43 // Given44 SerenityStories stories = new AStorySample("*PassingBehavior.story");45 stories.setSystemConfiguration(systemConfiguration);46 FixtureMethods.beforeScenarioCalledCount = 0;47 // When48 run(stories);49 // Then50 assertThat(FixtureMethods.beforeScenarioCalledCount, is(6));51 }52 final class AnotherStorySample extends SerenityStories {53 public AnotherStorySample() {54 super(environmentVariables);55 findStoriesCalled("stories/samples/*Behavior.story");56 }57 }58 @Test59 public void should_not_run_given_stories_separately() {60 // Given61 SerenityStories story = new AnotherStorySample();62 // When63 run(story);64 // Then65 List<TestOutcome> outcomes = loadTestOutcomes();66 assertThat(outcomes.size(), is(3));67 TestOutcome scenarioWithGivens = theScenarioCalled("some scenario with givens").in(outcomes);68// TestOutcome scenarioWithGivens = outcomes.get(2);69 assertThat(scenarioWithGivens.getTestSteps().size(), is(5));70 TestStep firstStep = scenarioWithGivens.getTestSteps().get(0);71 TestStep secondStep = scenarioWithGivens.getTestSteps().get(1);72 TestStep scenarioStep = scenarioWithGivens.getTestSteps().get(2);73 assertThat(firstStep.getDescription(), is("precondition description"));74 assertThat(secondStep.getDescription(), is("another precondition description"));75 assertThat(scenarioStep.getDescription(), is("Given a system state"));76 assertThat(firstStep.getChildren().size(), is(3));77 assertThat(secondStep.getChildren().size(), is(4));78 }79 final class AnotherSingleStorySample extends SerenityStories {80 public AnotherSingleStorySample() {81 super(environmentVariables);82 findStoriesCalled("stories/samples/SomeMoreBehavior.story");83 }84 }85 @Test86 public void should_count_preconditions_as_step() {87 // Given88 SerenityStories story = new AnotherSingleStorySample();89 // When90 run(story);91 // Then92 List<TestOutcome> outcomes = loadTestOutcomes();93 assertThat(outcomes.size(), is(1));94 TestOutcome scenarioWithGivens = outcomes.get(0);95 assertThat(scenarioWithGivens.getTestSteps().size(), is(5));96 TestStep firstStep = scenarioWithGivens.getTestSteps().get(0);...

Full Screen

Full Screen

Source:TestExecution.java Github

copy

Full Screen

...20 // configuredEmbedder().embedderControls().useThreads(2);21 String pathType = runConfig.getStoryPathType();22 if (pathType != null) {23 if (pathType.contentEquals("stories_called") && runConfig.getStoriesCalledPath() != null) {24 findStoriesCalled(runConfig.getStoriesCalledPath());25 }26 if (pathType.contentEquals("stories_in") && runConfig.getStoriesInPath() != null) {27 findStoriesIn(runConfig.getStoriesInPath());28 }29 }30 }31 32 @Override33 public List<String> storyPaths() {34 if (runConfig.getStoryPathType().contentEquals("stories_called") || runConfig.getStoryPathType().contentEquals("stories_in")) {35 return super.storyPaths();36 } else {37 return runConfig.getStoryOrderPaths();38 }...

Full Screen

Full Screen

Source:TestRunner.java Github

copy

Full Screen

...11 12 protected String storiesToRun = "greytHRLogin.story";13 protected String storiesFoldersToRun = "";14 public TestRunner(){15 findStoriesCalled(storiesToRun);16 //findStoriesIn(storiesFoldersToRun);17 }18 @Override19 public Configuration configuration(){20 return new MostUsefulConfiguration().useStoryLoader(new LoadFromClasspath(this.getClass().getClassLoader()))21 .useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE,Format.HTML));22 }23 24 @Override25 public InjectableStepsFactory stepsFactory(){26 return SerenityStepFactory.withStepsFromPackage(getstepsPackage(), configuration()).andClassLoader(getClassLoader());27 }28 public String getstepsPackage(){29 return "milvik.bima.mapper";...

Full Screen

Full Screen

Source:ABehaviorContainingSlowTests.java Github

copy

Full Screen

2import net.thucydides.core.webdriver.DriverConfiguration;3public class ABehaviorContainingSlowTests extends SerenityStories {4 public ABehaviorContainingSlowTests(DriverConfiguration configuration) {5 super(configuration);6 findStoriesCalled("**/aSlowBehavior.story");7 }8 public ABehaviorContainingSlowTests() {9 findStoriesCalled("**/aSlowBehavior.story");10 }11}...

Full Screen

Full Screen

Source:AcceptanceTestSuite.java Github

copy

Full Screen

...3public class AcceptanceTestSuite extends SerenityStories {4String directory_stories;5public AcceptanceTestSuite() {6directory_stories = "stories/tests_run/*/*";7findStoriesCalled(directory_stories);8}9}...

Full Screen

Full Screen

Source:interviewRunnerClass.java Github

copy

Full Screen

...3public class interviewRunnerClass extends SerenityStories{4 5 public interviewRunnerClass()6 {7 findStoriesCalled("test*.story");8 }9}...

Full Screen

Full Screen

Source:runnerClass.java Github

copy

Full Screen

...3public class runnerClass extends SerenityStories {4 5public runnerClass() {6 7 findStoriesCalled("*.story");8 }9}...

Full Screen

Full Screen

findStoriesCalled

Using AI Code Generation

copy

Full Screen

1 public List<String> storyPaths() {2 return findStoriesCalled("*.story");3 }4 public List<String> storyPaths() {5 return findStoriesCalled("*.story");6 }7 public List<String> storyPaths() {8 return findStoriesCalled("*.story");9 }10 public List<String> storyPaths() {11 return findStoriesCalled("*.story");12 }13 public List<String> storyPaths() {14 return findStoriesCalled("*.story");15 }16 public List<String> storyPaths() {17 return findStoriesCalled("*.story");18 }19 public List<String> storyPaths() {20 return findStoriesCalled("*.story");21 }22 public List<String> storyPaths() {23 return findStoriesCalled("*.story");24 }25 public List<String> storyPaths() {26 return findStoriesCalled("*.story");27 }28 public List<String> storyPaths() {29 return findStoriesCalled("*.story");30 }31 public List<String> storyPaths() {32 return findStoriesCalled("*.story");33 }

Full Screen

Full Screen

findStoriesCalled

Using AI Code Generation

copy

Full Screen

1 public class AcceptanceTestSuite extends SerenityStories {2 public AcceptanceTestSuite() {3 findStoriesCalled("**/*.story");4 }5 }6 public class AcceptanceTestSuite extends SerenityStories {7 public AcceptanceTestSuite() {8 findStoriesIn("src/test/resources");9 }10 }11 public class AcceptanceTestSuite extends SerenityStories {12 public AcceptanceTestSuite() {13 findStoriesIn("src/test/resources", "**/*.story");14 }15 }16 public class AcceptanceTestSuite extends SerenityStories {17 public AcceptanceTestSuite() {18 findStoriesIn("src/test/resources", "**/*.story", "**/excluded.story");19 }20 }21 public class AcceptanceTestSuite extends SerenityStories {22 public AcceptanceTestSuite() {23 findStoriesIn("src/test/resources", "**/*.story", "**/excluded.story", "**/pending.story");24 }25 }26 public class AcceptanceTestSuite extends SerenityStories {27 public AcceptanceTestSuite() {28 findStoriesIn("src/test/resources", "**/*.story", "**/excluded.story", "**/pending.story", "**/pending.story");29 }30 }31 public class AcceptanceTestSuite extends SerenityStories {32 public AcceptanceTestSuite() {33 findStoriesIn("src/test/resources", "**/*.story", "**/excluded.story", "**/pending.story", "**/pending.story", "**/pending.story");34 }35 }36 public class AcceptanceTestSuite extends SerenityStories {37 public AcceptanceTestSuite() {

Full Screen

Full Screen

findStoriesCalled

Using AI Code Generation

copy

Full Screen

1public class AcceptanceTestSuite extends SerenityStories {2 public AcceptanceTestSuite() {3 findStoriesCalled("**/story1.story");4 }5 public InjectableStepsFactory stepsFactory() {6 Configuration configuration = configuration();7 return new InstanceStepsFactory(configuration,8 new SampleSteps());9 }10}

Full Screen

Full Screen

findStoriesCalled

Using AI Code Generation

copy

Full Screen

1public class MyStory extends SerenityStories {2 public MyStory() {3 findStoriesCalled("MyStory.story");4 }5}6public class MyStory extends SerenityStories {7 public MyStory() {8 findStoriesCalled("MyStory.story");9 }10}11public class MyStory extends SerenityStories {12 public MyStory() {13 findStoriesCalled("MyStory");14 }15}16public class MyStory extends SerenityStories {17 public MyStory() {18 findStoriesCalled(".story");19 }20}21public class MyStory extends SerenityStories {22 public MyStory() {23 findStoriesCalled("MyStory.story").inDirectory("/src/test/resources/stories");24 }25}26public class MyStory extends SerenityStories {27 public MyStory() {28 findStoriesCalled("MyStory").inDirectory("/src/test/resources/stories");29 }30}

Full Screen

Full Screen

findStoriesCalled

Using AI Code Generation

copy

Full Screen

1public List<String> findStoriesIn(String path) throws IOException {2 return findStoriesCalled(path);3}4public List<String> findStoriesCalled(String path) throws IOException {5 List<String> stories = new ArrayList<String>();6 File storyDir = new File(path);7 if (storyDir.exists()) {8 for (File story : storyDir.listFiles()) {9 if (story.isFile() && story.getName().endsWith(".story")) {10 stories.add(story.getAbsolutePath());11 }12 }13 }14 return stories;15}16public List<String> findStoriesIn(String path) throws IOException {17 List<String> stories = new ArrayList<String>();18 File storyDir = new File(path);19 if (storyDir.exists()) {20 for (File story : storyDir.listFiles()) {21 if (story.isFile() && story.getName().endsWith(".story")) {22 stories.add(story.getAbsolutePath());23 }24 }25 }26 return stories;27}28public List<String> findStoriesIn(String path) throws IOException {29 List<String> stories = new ArrayList<String>();30 File storyDir = new File(path);31 if (storyDir.exists()) {32 for (File story : storyDir.listFiles()) {33 if (story.isFile() && story.getName().endsWith(".story")) {34 stories.add(story.getAbsolutePath());35 }36 }37 }38 return stories;39}40public List<String> findStoriesIn(String path) throws IOException {41 List<String> stories = new ArrayList<String>();42 File storyDir = new File(path);43 if (storyDir.exists()) {44 for (File story : storyDir.listFiles()) {45 if (story.isFile() && story.getName().endsWith(".story")) {46 stories.add(story.getAbsolutePath());47 }48 }49 }50 return stories;51}52public List<String> findStoriesIn(String path) throws IOException {53 List<String> stories = new ArrayList<String>();54 File storyDir = new File(path);

Full Screen

Full Screen

findStoriesCalled

Using AI Code Generation

copy

Full Screen

1package net.serenitybdd.jbehave;2import net.thucydides.core.ThucydidesSystemProperty;3import net.thucydides.core.util.EnvironmentVariables;4import net.thucydides.core.util.SystemEnvironmentVariables;5import org.jbehave.core.configuration.Configuration;6import org.jbehave.core.io.StoryFinder;7import org.jbehave.core.junit.JUnitStories;8import org.jbehave.core.reporters.StoryReporterBuilder;9import org.jbehave.core.steps.InjectableStepsFactory;10import org.jbehave.core.steps.InstanceStepsFactory;11import org.jbehave.core.steps.ParameterConverters;12import org.jbehave.core.steps.ParameterConverters.DateConverter;13import org.jbehave.core.steps.ParameterConverters.ExamplesTableConverter;14import org.jbehave.web.selenium.*;15import java.text.SimpleDateFormat;16import java.util.List;17import java.util.Properties;18import static java.util.Arrays.asList;19public class SerenityStories extends JUnitStories {20 private final EnvironmentVariables environmentVariables;21 public SerenityStories() {22 this(new SystemEnvironmentVariables());23 }24 public SerenityStories(EnvironmentVariables environmentVariables) {25 this.environmentVariables = environmentVariables;26 configuredEmbedder().embedderControls()27 .doGenerateViewAfterStories(true)28 .doIgnoreFailureInStories(true)29 .doIgnoreFailureInView(true)30 .doVerboseFailures(true)31 .useThreads(1)32 .useStoryTimeoutInSecs(300);33 }34 public Configuration configuration() {35 Class<? extends SerenityStories> storyClass = this.getClass();36 Class<? extends SerenityStories> baseStoryClass = SerenityStories.class;37 String storyName = storyClass.getName().replace(baseStoryClass.get

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful