How to use pending method of net.serenitybdd.jbehave.SerenityReporter class

Best Serenity jBehave code snippet using net.serenitybdd.jbehave.SerenityReporter.pending

Source:SerenityReporter.java Github

copy

Full Screen

...40 private final List<BaseStepListener> baseStepListeners;41 private final DriverConfiguration systemConfiguration;42 private static final String OPEN_PARAM_CHAR = "\uff5f";43 private static final String CLOSE_PARAM_CHAR = "\uff60";44 private static final String PENDING = "pending";45 private static final String MANUAL = "manual";46 private static final String SKIP = "skip";47 private static final String WIP = "wip";48 private static final String IGNORE = "ignore";49 private static final String BEFORE_STORIES = "BeforeStories";50 private static final String AFTER_STORIES = "AfterStories";51 private GivenStoryMonitor givenStoryMonitor;52 private final EnvironmentVariables environmentVariables;53 public SerenityReporter(DriverConfiguration systemConfiguration) {54 this.systemConfiguration = systemConfiguration;55 serenityListenersThreadLocal = new ThreadLocal<>();56 reportServiceThreadLocal = new ThreadLocal<>();57 baseStepListeners = new ArrayList<>();58 givenStoryMonitor = new GivenStoryMonitor();59 this.environmentVariables = Injectors.getInjector().getInstance(EnvironmentVariables.class);60 }61 protected void clearListeners() {62 serenityListenersThreadLocal.remove();63 reportServiceThreadLocal.remove();64 givenStoryMonitor.clear();65 }66 protected SerenityListeners getSerenityListeners() {67 if (serenityListenersThreadLocal.get() == null) {68 SerenityListeners listeners = SerenityReports.setupListeners(systemConfiguration);69 serenityListenersThreadLocal.set(listeners);70 synchronized (baseStepListeners) {71 baseStepListeners.add(listeners.getBaseStepListener());72 }73 }74 return serenityListenersThreadLocal.get();75 }76 protected ReportService getReportService() {77 return SerenityReports.getReportService(systemConfiguration);78 }79 @Override80 public void storyNotAllowed(Story story, String filter) {81 logger.debug("not allowed story {}", story.getName());82 }83 @Override84 public void storyCancelled(Story story, StoryDuration storyDuration) {85 logger.debug("cancelled story {}", story.getName());86 }87 private Stack<Story> storyStack = new Stack<>();88 private Stack<Scenario> activeScenarios = new Stack<>();89 private List<String> givenStories = new ArrayList<>();90 private Story currentStory() {91 return storyStack.peek();92 }93 private void currentStoryIs(Story story) {94 storyStack.push(story);95 }96 private Map<String, String> storyMetadata;97 private void clearActiveScenariosData() {98 activeScenarios.clear();99 }100 @Override101 public void beforeStory(Story story, boolean givenStory) {102 logger.debug("before story {}", story.getName());103 prepareSerenityListeners();104 currentStoryIs(story);105 noteAnyGivenStoriesFor(story);106 storyMetadata = getMetadataFrom(story.getMeta());107 if (!isFixture(story) && !givenStory) {108 clearActiveScenariosData();109 configureDriver(story);110 SerenityStepFactory.resetContext();111 if (!isAStoryLevelGiven(story)) {112 startTestSuiteForStory(story);113 if (givenStoriesPresentFor(story)) {114 startTestForFirstScenarioIn(story);115 }116 }117 } else if (givenStory) {118 shouldNestScenarios(true);119 }120 registerStoryMeta(story.getMeta());121 }122 private void prepareSerenityListeners() {123 getSerenityListeners().withDriver(ThucydidesWebDriverSupport.getDriver());124 }125 private boolean nestScenarios = false;126 private boolean shouldNestScenarios() {127 return nestScenarios;128 }129 private void shouldNestScenarios(boolean nestScenarios) {130 this.nestScenarios = nestScenarios;131 }132 private void startTestForFirstScenarioIn(Story story) {133 startScenarioCalled(story.getScenarios().get(0), story);134 StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle("Preconditions"));135 shouldNestScenarios(true);136 }137 @Override138 public void beforeScenario(Scenario scenario) {139 String scenarioTitle = scenario.getTitle();140 logger.debug("before scenario started {}", scenarioTitle);141 if (shouldResetStepsBeforeEachScenario()) {142 SerenityStepFactory.resetContext();143 }144 resetDriverIfNecessary();145 if (isCurrentScenario(scenarioTitle)) {146 return;147 }148 if (shouldNestScenarios()) {149 startNewStep(scenarioTitle);150 } else {151 startScenarioCalled(scenario, currentStory());152 }153 Meta meta = scenario.getMeta();154 logger.debug("scenario:\"{}\" registering metadata for {}",155 StringUtils.isEmpty(scenarioTitle) ? " don't know name " : scenarioTitle, meta);156 registerIssues(meta);157 registerFeaturesAndEpics(meta);158 registerTags(meta);159 registerMetadata(meta);160 registerScenarioMeta(meta);161 markAsSkippedOrPendingIfAnnotatedAsSuchIn(scenarioTags(scenario));162 }163 private List<String> scenarioTags(Scenario scenario) {164 List<String> scenarioTags = new ArrayList<>(scenario.getMeta().getPropertyNames());165 scenarioTags.addAll(currentStory().getMeta().getPropertyNames());166 return scenarioTags;167 }168 private void resetDriverIfNecessary() {169 if (Serenity.currentDriverIsDisabled()) {170 Serenity.getWebdriverManager().resetDriver();171 }172 }173 private boolean isCurrentScenario(String scenarioTitle) {174 return !activeScenarios.empty() && scenarioTitle.equals(activeScenarios.peek().getTitle());175 }176 private Scenario currentScenario() {177 return activeScenarios.peek();178 }179 private void startNewStep(String scenarioTitle) {180 if (givenStoryMonitor.isInGivenStory() && StepEventBus.getEventBus().areStepsRunning()) {181 StepEventBus.getEventBus().updateCurrentStepTitleAsPrecondition(scenarioTitle);182 } else {183 StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle(scenarioTitle),184 givenStoryMonitor.isInGivenStory());185 }186 }187 private boolean givenStoriesPresentFor(Story story) {188 return !story.getGivenStories().getStories().isEmpty();189 }190 private void startTestSuiteForStory(Story story) {191 String storyName = removeSuffixFrom(story.getName());192 String storyTitle = (isNotEmpty(story.getDescription().asString())) ? story.getDescription().asString() : NameConverter.humanize(storyName);193 net.thucydides.core.model.Story userStory194 = net.thucydides.core.model.Story.withIdAndPath(storyName, storyTitle, stripStoriesFolderFrom(story.getPath()))195 .withNarrative(getNarrativeFrom(story));196 StepEventBus.getEventBus().testSuiteStarted(userStory);197 registerTags(story);198 }199 private String stripStoriesFolderFrom(String path) {200 String storyDirectory = environmentVariables.getProperty(STORY_DIRECTORY,"stories");201 return (path.toLowerCase().startsWith(storyDirectory + "/")) ? path.substring(storyDirectory.length() + 1) : path;202 }203 private String getNarrativeFrom(Story story) {204 return (!story.getNarrative().isEmpty()) ?205 story.getNarrative().asString(new Keywords()).trim() : "";206 }207 private void noteAnyGivenStoriesFor(Story story) {208 for (GivenStory given : story.getGivenStories().getStories()) {209 String givenStoryName = new File(given.getPath()).getName();210 givenStories.add(givenStoryName);211 }212 }213 private boolean isAStoryLevelGiven(Story story) {214 for (String givenStoryName : givenStories) {215 if (hasSameName(story, givenStoryName)) {216 return true;217 }218 }219 return false;220 }221 private void givenStoryDone(Story story) {222 givenStories.remove(story.getName());223 }224 private boolean hasSameName(Story story, String givenStoryName) {225 return story.getName().equalsIgnoreCase(givenStoryName);226 }227 private void configureDriver(Story story) {228 StepEventBus.getEventBus().setUniqueSession(systemConfiguration.shouldUseAUniqueBrowser());229 String requestedDriver = getRequestedDriver(story.getMeta());230 // An annotated driver that ends with "!" overrides the command-line configured driver231 if (isEmphatic(requestedDriver)) {232 ThucydidesWebDriverSupport.useDefaultDriver(unemphasised(requestedDriver));233 } else if (StringUtils.isNotEmpty(requestedDriver) && (!driverIsProvidedInTheEnvironmentVariables())){234 ThucydidesWebDriverSupport.useDefaultDriver(requestedDriver);235 }236 }237 private String unemphasised(String requestedDriver) {238 return requestedDriver.replace("!","");239 }240 private boolean isEmphatic(String requestedDriver) {241 return requestedDriver != null && requestedDriver.endsWith("!");242 }243 private boolean driverIsProvidedInTheEnvironmentVariables() {244 return (isNotEmpty(systemConfiguration.getEnvironmentVariables().getProperty(WEBDRIVER_DRIVER)));245 }246 private void registerTags(Story story) {247 registerStoryIssues(story.getMeta());248 registerStoryFeaturesAndEpics(story.getMeta());249 registerStoryTags(story.getMeta());250 registerStoryMeta(story.getMeta());251 }252 private boolean isFixture(Story story) {253 return (story.getName().equals(BEFORE_STORIES) || story.getName().equals(AFTER_STORIES));254 }255 private String getRequestedDriver(Meta metaData) {256 if (metaData == null) {257 return null;258 }259 if (StringUtils.isNotEmpty(metaData.getProperty("driver"))) {260 return metaData.getProperty("driver");261 }262 if (systemConfiguration.getDriverType() != null) {263 return systemConfiguration.getDriverType().toString();264 }265 return null;266 }267 private List<String> getIssueOrIssuesPropertyValues(Meta metaData) {268 return getTagPropertyValues(metaData, "issue");269 }270 private List<TestTag> getFeatureOrFeaturesPropertyValues(Meta metaData) {271 List<String> features = getTagPropertyValues(metaData, "feature");272 return features.stream().map(273 featureName -> TestTag.withName(featureName).andType("feature")274 ).collect(Collectors.toList());275 }276 private List<TestTag> getEpicOrEpicsPropertyValues(Meta metaData) {277 List<String> epics = getTagPropertyValues(metaData, "epic");278 return epics.stream().map(279 epicName -> TestTag.withName(epicName).andType("epic")280 ).collect(Collectors.toList());281 }282 private List<TestTag> getTagOrTagsPropertyValues(Meta metaData) {283 List<String> tags = getTagPropertyValues(metaData, "tag");284 return tags.stream()285 .map( this::toTag )286 .collect(Collectors.toList());287 }288 public TestTag toTag(String tag) {289 List<String> tagParts = Lists.newArrayList(Splitter.on(":").trimResults().split(tag));290 if (tagParts.size() == 2) {291 return TestTag.withName(tagParts.get(1)).andType(tagParts.get(0));292 } else {293 return TestTag.withName("true").andType(tagParts.get(0));294 }295 }296 private List<String> getTagPropertyValues(Meta metaData, String tagType) {297 if (metaData == null) {298 return new ArrayList<>();299 }300 String singularTag = metaData.getProperty(tagType);301 String pluralTagType = Inflector.getInstance().pluralize(tagType);302 String multipleTags = metaData.getProperty(pluralTagType);303 String allTags = Joiner.on(',').skipNulls().join(singularTag, multipleTags);304 return Lists.newArrayList(Splitter.on(',').omitEmptyStrings().trimResults().split(allTags));305 }306 private void registerIssues(Meta metaData) {307 List<String> issues = getIssueOrIssuesPropertyValues(metaData);308 if (!issues.isEmpty()) {309 StepEventBus.getEventBus().addIssuesToCurrentTest(issues);310 }311 }312 private void registerStoryIssues(Meta metaData) {313 List<String> issues = getIssueOrIssuesPropertyValues(metaData);314 if (!issues.isEmpty()) {315 StepEventBus.getEventBus().addIssuesToCurrentStory(issues);316 }317 }318 private void registerFeaturesAndEpics(Meta metaData) {319 List<TestTag> featuresAndEpics = featureAndEpicTags(metaData);320 if (!featuresAndEpics.isEmpty()) {321 StepEventBus.getEventBus().addTagsToCurrentTest(featuresAndEpics);322 }323 }324 private List<TestTag> featureAndEpicTags(Meta metaData) {325 List<TestTag> featuresAndEpics = new ArrayList<>();326 featuresAndEpics.addAll(getFeatureOrFeaturesPropertyValues(metaData));327 featuresAndEpics.addAll(getEpicOrEpicsPropertyValues(metaData));328 return featuresAndEpics;329 }330 private void registerStoryFeaturesAndEpics(Meta metaData) {331 List<TestTag> featuresAndEpics = featureAndEpicTags(metaData);332 if (!featuresAndEpics.isEmpty()) {333 StepEventBus.getEventBus().addTagsToCurrentStory(featuresAndEpics);334 }335 }336 private void registerTags(Meta metaData) {337 List<TestTag> tags = getTagOrTagsPropertyValues(metaData);338 if (!tags.isEmpty()) {339 StepEventBus.getEventBus().addTagsToCurrentTest(tags);340 }341 }342 private Map<String, String> getMetadataFrom(Meta metaData) {343 Map<String, String> metadataValues = new HashMap<>();344 if (metaData == null) {345 return metadataValues;346 }347 for (String propertyName : metaData.getPropertyNames()) {348 metadataValues.put(propertyName, metaData.getProperty(propertyName));349 }350 return metadataValues;351 }352 private void registerMetadata(Meta metaData) {353 Serenity.getCurrentSession().clearMetaData();354 Map<String, String> scenarioMetadata = getMetadataFrom(metaData);355 scenarioMetadata.putAll(storyMetadata);356 for (String key : scenarioMetadata.keySet()) {357 Serenity.getCurrentSession().addMetaData(key, scenarioMetadata.get(key));358 }359 }360 private void registerStoryTags(Meta metaData) {361 List<TestTag> tags = getTagOrTagsPropertyValues(metaData);362 if (!tags.isEmpty()) {363 StepEventBus.getEventBus().addTagsToCurrentStory(tags);364 }365 }366 private void registerStoryMeta(Meta metaData) {367 if (isPending(metaData)) {368 StepEventBus.getEventBus().suspendTest();369 } else if (isSkipped(metaData)) {370 StepEventBus.getEventBus().suspendTest();371 } else if (isIgnored(metaData)) {372 StepEventBus.getEventBus().suspendTest();373 } else if (isManual(metaData)) {374 StepEventBus.getEventBus().suspendTest();375 }376 }377 private boolean isStoryManual() {378 return isManual(currentStory().getMeta());379 }380 private void registerScenarioMeta(Meta metaData) {381 // Manual can be combined with the other tags to override the default result category382 if (isManual(metaData) || isStoryManual()) {383 StepEventBus.getEventBus().testIsManual();384 }385 }386 private String removeSuffixFrom(String name) {387 return (name.contains(".")) ? name.substring(0, name.indexOf(".")) : name;388 }389 @Override390 public void afterStory(boolean given) {391 logger.debug("afterStory {}", given);392 shouldNestScenarios(false);393 if (given) {394 givenStoryMonitor.exitingGivenStory();395 givenStoryDone(currentStory());396 } else {397 if (isAfterStory(currentStory())) {398 generateReports();399 } else if (!isFixture(currentStory()) && (!isAStoryLevelGiven(currentStory()))) {400 StepEventBus.getEventBus().testSuiteFinished();401 clearListeners();402 }403 }404 storyStack.pop();405 }406 private boolean isAfterStory(Story currentStory) {407 return (currentStory.getName().equals(AFTER_STORIES));408 }409 private synchronized void generateReports() {410 getReportService().generateReportsFor(getAllTestOutcomes());411 }412 public List<TestOutcome> getAllTestOutcomes() {413 return baseStepListeners.stream()414 .map(BaseStepListener::getTestOutcomes)415 .flatMap(Collection::stream)416 .collect(Collectors.toList());417 }418 @Override419 public void narrative(Narrative narrative) {420 logger.debug("narrative {}", narrative);421 }422 @Override423 public void lifecyle(Lifecycle lifecycle) {424 logger.debug("lifecyle {}", lifecycle);425 }426 @Override427 public void scenarioNotAllowed(Scenario scenario, String s) {428 logger.debug("scenarioNotAllowed {}", scenario.getTitle());429 StepEventBus.getEventBus().testIgnored();430 }431 private void startScenarioCalled(Scenario scenario, Story story) {432 StepEventBus.getEventBus().setTestSource(TEST_SOURCE_JBEHAVE.getValue());433 StepEventBus.getEventBus().testStarted(scenario.getTitle(), story.getPath() + ";" + scenario.getTitle());434 activeScenarios.add(scenario);435 }436 private boolean shouldResetStepsBeforeEachScenario() {437 return systemConfiguration.getEnvironmentVariables().getPropertyAsBoolean(438 SerenityJBehaveSystemProperties.RESET_STEPS_EACH_SCENARIO.getName(), true);439 }440 private void markAsSkippedOrPendingIfAnnotatedAsSuchIn(List<String> tags) {441 if (isManual(tags)) {442 StepEventBus.getEventBus().testIsManual();443 }444 if (isSkipped(tags)) {445 StepEventBus.getEventBus().testSkipped();446 StepEventBus.getEventBus().getBaseStepListener().overrideResultTo(TestResult.SKIPPED);447 }448 if (isPending(tags)) {449 StepEventBus.getEventBus().testPending();450 StepEventBus.getEventBus().getBaseStepListener().overrideResultTo(TestResult.PENDING);451 }452 if (isIgnored(tags)) {453 StepEventBus.getEventBus().testIgnored();454 StepEventBus.getEventBus().getBaseStepListener().overrideResultTo(TestResult.IGNORED);455 }456 }457 private boolean isSkipped(List<String> tags) {458 return tags.contains("skip") || tags.contains("wip");459 }460 private boolean isPending(List<String> tags) {461 return tags.contains("pending");462 }463 private boolean isIgnored(List<String> tags) {464 return tags.contains("ignore");465 }466 private boolean isManual(List<String> tags) {467 return tags.contains("manual");468 }469 private boolean isPending(Meta metaData) {470 return metaData != null && (metaData.hasProperty(PENDING));471 }472 private boolean isManual(Meta metaData) {473 return metaData != null && (metaData.hasProperty(MANUAL));474 }475 private boolean isSkipped(Meta metaData) {476 return metaData != null && (metaData.hasProperty(WIP) || metaData.hasProperty(SKIP));477 }478 private boolean isCandidateToBeExecuted(Meta metaData) {479 return !isIgnored(metaData) && !isPending(metaData) && !isSkipped(metaData);480 }481 private boolean isIgnored(Meta metaData) {482 return metaData != null && (metaData.hasProperty(IGNORE));483 }484 @Override485 public void afterScenario() {486 Scenario scenario = currentScenario();487 logger.debug("afterScenario : {}", scenario.getTitle());488 List<String> scenarioTags = scenarioTags(scenario);489 markAsSkippedOrPendingIfAnnotatedAsSuchIn(scenarioTags);490 if (givenStoryMonitor.isInGivenStory() || shouldNestScenarios()) {491 StepEventBus.getEventBus().stepFinished();492 } else {493 if (!(isPending(scenarioTags) || isSkipped(scenarioTags) || isIgnored(scenarioTags))) {494 StepEventBus.getEventBus().testFinished(executingExamples());495 }496 activeScenarios.pop();497 }498 ThucydidesWebDriverSupport.clearStepLibraries();499 }500 @Override501 public void givenStories(GivenStories givenStories) {502 logger.debug("givenStories {}", givenStories);503 givenStoryMonitor.enteringGivenStory();504 }505 @Override506 public void givenStories(List<String> strings) {507 logger.debug("givenStories {}", strings);508 }509 int exampleCount = 0;510 @Override511 public void beforeExamples(List<String> steps, ExamplesTable table) {512 logger.debug("beforeExamples {} {}", steps, table);513 if (givenStoryMonitor.isInGivenStory()) {514 return;515 }516 exampleCount = 0;517 StepEventBus.getEventBus().useExamplesFrom(serenityTableFrom(table));518 }519 private DataTable serenityTableFrom(ExamplesTable table) {520 String scenarioOutline = scenarioOutlineFrom(currentScenario());521 return DataTable.withHeaders(table.getHeaders())522 .andScenarioOutline(scenarioOutline)523 .andMappedRows(table.getRows())524 .build();525 }526 private String scenarioOutlineFrom(Scenario scenario) {527 StringBuilder outline = new StringBuilder();528 for (String step : scenario.getSteps()) {529 outline.append(step.trim()).append(System.lineSeparator());530 }531 return outline.toString();532 }533 @Override534 public void example(Map<String, String> tableRow, int exampleIndex) {535 StepEventBus.getEventBus().clearStepFailures();536 if (givenStoryMonitor.isInGivenStory()) {537 return;538 }539 if (executingExamples()) {540 finishExample();541 }542 exampleCount++;543 startExample(tableRow);544 }545 private void startExample(Map<String, String> data) {546 StepEventBus.getEventBus().exampleStarted(data);547 }548 private void finishExample() {549 StepEventBus.getEventBus().exampleFinished();550 }551 private boolean executingExamples() {552 return (exampleCount > 0);553 }554 @Override555 public void afterExamples() {556 if (givenStoryMonitor.isInGivenStory()) {557 return;558 }559 finishExample();560 }561 @Override562 public void beforeStep(String stepTitle) {563 StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle(stepTitle));564 }565 @Override566 public void successful(String title) {567 if (annotatedResultTakesPriority()) {568 processAnnotatedResult();569 } else {570 StepEventBus.getEventBus().updateCurrentStepTitle(normalized(title));571 StepEventBus.getEventBus().stepFinished();572 }573 }574 private void processAnnotatedResult() {575 TestResult forcedResult = StepEventBus.getEventBus().getForcedResult().get();576 switch (forcedResult) {577 case PENDING:578 StepEventBus.getEventBus().stepPending();579 break;580 case IGNORED:581 StepEventBus.getEventBus().stepIgnored();582 break;583 case SKIPPED:584 StepEventBus.getEventBus().stepIgnored();585 break;586 default:587 StepEventBus.getEventBus().stepIgnored();588 }589 }590 private boolean annotatedResultTakesPriority() {591 return StepEventBus.getEventBus().getForcedResult().isPresent();592 }593 @Override594 public void ignorable(String title) {595 StepEventBus.getEventBus().updateCurrentStepTitle(normalized(title));596 StepEventBus.getEventBus().stepIgnored();597 }598 @Override599 public void comment(String step) {600 StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle(step));601 StepEventBus.getEventBus().stepIgnored();602 }603 @Override604 public void pending(String stepTitle) {605 StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle(normalized(stepTitle)));606 StepEventBus.getEventBus().stepPending();607 }608 @Override609 public void notPerformed(String stepTitle) {610 StepEventBus.getEventBus().stepStarted(ExecutedStepDescription.withTitle(normalized(stepTitle)));611 StepEventBus.getEventBus().stepIgnored();612 }613 @Override614 public void failed(String stepTitle, Throwable cause) {615 if (!StepEventBus.getEventBus().testSuiteHasStarted()) {616 declareOutOfSuiteFailure();617 }618 if (!errorOrFailureRecordedForStep(cause.getCause())) {619 StepEventBus.getEventBus().updateCurrentStepTitle(stepTitle);620 Throwable rootCause = new RootCauseAnalyzer(cause.getCause()).getRootCause().toException();621 if (isAssumptionFailure(rootCause)) {622 StepEventBus.getEventBus().assumptionViolated(rootCause.getMessage());623 } else {624 StepEventBus.getEventBus().stepFailed(new StepFailure(ExecutedStepDescription.withTitle(normalized(stepTitle)), rootCause));625 }626 }627 }628 private void declareOutOfSuiteFailure() {629 String storyName = !storyStack.isEmpty() ? storyStack.peek().getName() : "Before or After Story";630 String storyId = !storyStack.isEmpty() ? storyStack.peek().getPath() : null;631 StepEventBus.getEventBus().testStarted(storyName, storyId);632 }633 private boolean isAssumptionFailure(Throwable rootCause) {634 return (AssumptionViolatedException.class.isAssignableFrom(rootCause.getClass()));635 }636 public List<String> processExcludedByFilter(final Story story, final Set<String> exclude) {637 final Meta storyMeta = story.getMeta();638 final List<Scenario> processing = new LinkedList<>();639 final List<String> processed = new LinkedList<>();640 if (isSkipped(storyMeta) || isIgnored(storyMeta)) { //this story should be excluded by filter641 processing.addAll(story.getScenarios());642 } else {643 for (Scenario scenario : story.getScenarios()) {644 final Meta scenarioMeta = scenario.getMeta();645 if (isSkipped(scenarioMeta) || isIgnored(scenarioMeta)) { //this scenario should be excluded by filter646 processing.add(scenario);647 }648 }649 }650 if (processing.size() > 0) {651 final Story beforeStory = new Story();652 beforeStory.namedAs(BEFORE_STORIES);653 final Story afterStory = new Story();654 afterStory.namedAs(AFTER_STORIES);655 final Narrative narrative = story.getNarrative();656 beforeStory(beforeStory, false);657 afterStory(false);658 beforeStory(story, false);659 narrative(narrative);660 for (final Scenario filtered : processing) {661 final String scenarioKey = scenarioKey(story, filtered);662 if (!exclude.contains(scenarioKey)) {663 beforeScenario(filtered);664 final List<String> steps = filtered.getSteps();665 if (ExamplesTable.EMPTY == filtered.getExamplesTable() || filtered.getExamplesTable().getRows().size() == 0) {666 for (final String step : steps) {667 beforeStep(step);668 successful(step);669 }670 } else {671 final ExamplesTable examples = filtered.getExamplesTable();672 beforeExamples(steps, examples);673 for (final Map<String, String> row : examples.getRows()) {674 example(row);675 for (final String step : steps) {676 beforeStep(step);677 successful(step);678 }679 }680 afterExamples();681 }682 afterScenario();683 processed.add(scenarioKey(story, filtered));684 }685 }686 afterStory(false);687 beforeStory(afterStory, false);688 afterStory(false);689 }690 return processed;691 }692 private String scenarioKey(final Story story, final Scenario scenario) {693 return story.getPath().concat(scenario.getTitle());694 }695 @Override696 public void failedOutcomes(String s, OutcomesTable outcomesTable) {697 logger.debug("failedOutcomes");698 }699 @Override700 public void restarted(String s, Throwable throwable) {701 logger.debug("restarted");702 }703 @Override704 public void restartedStory(Story story, Throwable cause) {705 logger.debug("restartedStory");706 }707 @Override708 public void dryRun() {709 logger.debug("dryRun");710 }711 @Override712 public void pendingMethods(List<String> strings) {713 logger.debug("pendingMethods");714 }715 private String normalized(String value) {716 return value.replaceAll(OPEN_PARAM_CHAR, "{").replaceAll(CLOSE_PARAM_CHAR, "}");717 }718 private boolean errorOrFailureRecordedForStep(Throwable cause) {719 if (!latestTestOutcome().isPresent()) {720 return false;721 }722 for (TestStep step : latestTestOutcome().get().getFlattenedTestSteps()) {723 if ((step.getException() != null) && (step.getException().getOriginalCause() == cause)) {724 return true;725 }726 }727 return false;...

Full Screen

Full Screen

Source:14267.java Github

copy

Full Screen

1private boolean isPending(net.serenitybdd.jbehave.Meta metaData) {2 if (metaData == null)3 return false;4 5 return metaData.hasProperty(net.serenitybdd.jbehave.SerenityReporter.PENDING);...

Full Screen

Full Screen

pending

Using AI Code Generation

copy

Full Screen

1import net.serenitybdd.jbehave.SerenityReporter;2import net.thucydides.core.annotations.Pending;3public class SerenityReporterPendingMethod extends SerenityReporter {4 public void example(Map<String, String> data) {5 System.out.println("example method");6 }7 public void pending() {8 System.out.println("pending method");9 }10}11import net.serenitybdd.jbehave.SerenityReporter;12import net.thucydides.core.annotations.Pending;13public class SerenityReporterPendingMethod extends SerenityReporter {14 public void example(Map<String, String> data) {15 System.out.println("example method");16 pending();17 }18 public void pending() {19 System.out.println("pending method");20 }21}22The pending() method of SerenityReporter class is used to mark the example as pending. The pending() method is called from the example() method of SerenityReporter class. The example() method is overridden in the SerenityReporterPendingMethod class. The example() method is called when the example is executed. The example() method prints the message “example method” and calls the pending() method. The pending() method is marked with

Full Screen

Full Screen

pending

Using AI Code Generation

copy

Full Screen

1import net.serenitybdd.jbehave.SerenityReporter;2public class SerenityReporterTest extends SerenityReporter{3 @Given("some step")4 public void someStep(){5 pending();6 }7}8import net.serenitybdd.jbehave.SerenityStory;9public class SerenityStoryTest extends SerenityStory{10 @Given("some step")11 public void someStep(){12 pending();13 }14}15import net.serenitybdd.jbehave.SerenitySteps;16public class SerenityStepsTest extends SerenitySteps{17 @Given("some step")18 public void someStep(){19 pending();20 }21}22import net.serenitybdd.jbehave.SerenityStepFactory;23public class SerenityStepFactoryTest extends SerenityStepFactory{24 @Given("some step")25 public void someStep(){26 pending();27 }28}29import net.serenitybdd.jbehave.SerenityStepFactory;30public class SerenityStepFactoryTest extends SerenityStepFactory{31 @Given("some step")32 public void someStep(){33 pending();34 }35}36import net.serenitybdd.jbehave.SerenityStepFactory;37public class SerenityStepFactoryTest extends SerenityStepFactory{38 @Given("some step")39 public void someStep(){40 pending();41 }42}43import net.serenitybdd.jbehave.SerenityStepFactory;44public class SerenityStepFactoryTest extends SerenityStepFactory{45 @Given("some step")46 public void someStep(){47 pending();48 }49}50import net.serenitybdd.jbehave.SerenityStepFactory;

Full Screen

Full Screen

pending

Using AI Code Generation

copy

Full Screen

1 public void pendingStep() {2 }3public void pendingStep() { 4}5public void pendingStep() { 6}7public void pendingStep() { 8}9public void pendingStep() { 10}11public void pendingStep() { 12}13public void pendingStep() { 14}15public void pendingStep() { 16}17public void pendingStep() { 18}19public void pendingStep() { 20}21public void pendingStep() { 22}

Full Screen

Full Screen

pending

Using AI Code Generation

copy

Full Screen

1 @Then("the user should see the message <message>")2 public void theUserShouldSeeTheMessage(String message) {3 assertThat(message).isEqualTo("Hello");4 }5}6@Then("the user should see the message <message>")7public void theUserShouldSeeTheMessage(String message) {8 assertThat(message).isEqualTo("Hello");9 StepEventBus.getEventBus().pendingStepFound();10}11@Then("the user should see the message <message>")12public void theUserShouldSeeTheMessage(String message) {13 assertThat(message).isEqualTo("Hello");14 StepEventBus.getEventBus().pendingStepFound();15}

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