gherkin.events.PickleEvent Java Examples
The following examples show how to use
gherkin.events.PickleEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoopConverter.java From bdt with Apache License 2.0 | 7 votes |
public static List<PickleEvent> transformPickleEventWithLoopTags(PickleEvent pe) { List<PickleEvent> pickleEventList = new ArrayList<>(); for (PickleTag pickleTag : pe.pickle.getTags()) { // Loop if (pickleTag.getName().toUpperCase().matches("\\s*@LOOP.*")) { transformLoop(pe, pickleTag, pickleEventList); break; } // ProgLoop if (pickleTag.getName().toUpperCase().matches("\\s*@PROGLOOP.*")) { transformProgLoop(pe, pickleTag, pickleEventList); break; } // MultiLoop if (pickleTag.getName().toUpperCase().matches("\\s*@MULTILOOP.*")) { transformMultiLoop(pe, pickleTag, pickleEventList); break; } } if (pickleEventList.isEmpty()) { pickleEventList.add(pe); } return pickleEventList; }
Example #2
Source File: AllureCucumber4JvmTest.java From allure-java with Apache License 2.0 | 6 votes |
private byte runFeature(final AllureResultsWriterStub writer, final String featureResource, final String... moreOptions) { final AllureLifecycle lifecycle = new AllureLifecycle(writer); final AllureCucumber4Jvm cucumber4Jvm = new AllureCucumber4Jvm(lifecycle); final ClassLoader classLoader = currentThread().getContextClassLoader(); final ResourceLoader resourceLoader = new MultiLoader(classLoader); final ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); final List<String> opts = new ArrayList<>(Arrays.asList( "--glue", "io.qameta.allure.cucumber4jvm.samples", "--plugin", "null_summary" )); opts.addAll(Arrays.asList(moreOptions)); final RuntimeOptions options = new CommandlineOptionsParser().parse(opts).build(); boolean mt = options.isMultiThreaded(); FeatureSupplier featureSupplier = () -> { try { final String gherkin = readResource(featureResource); Parser<GherkinDocument> parser = new Parser<>(new AstBuilder()); TokenMatcher matcher = new TokenMatcher(); GherkinDocument gherkinDocument = parser.parse(gherkin, matcher); List<PickleEvent> pickleEvents = compilePickles(gherkinDocument, featureResource); CucumberFeature feature = new CucumberFeature(gherkinDocument, URI.create(featureResource), gherkin, pickleEvents); return Collections.singletonList(feature); } catch (IOException e) { return Collections.EMPTY_LIST; } }; final Runtime runtime = Runtime.builder() .withResourceLoader(resourceLoader) .withClassFinder(classFinder) .withClassLoader(classLoader) .withRuntimeOptions(options) .withAdditionalPlugins(cucumber4Jvm) .withFeatureSupplier(featureSupplier) .build(); runtime.run(); return runtime.exitStatus(); }
Example #3
Source File: CucumberRunner.java From bdt with Apache License 2.0 | 6 votes |
/** * @return returns the cucumber scenarios as a two dimensional array of {@link PickleEventWrapper} * scenarios combined with their {@link CucumberFeatureWrapper} feature. */ public Object[][] provideScenarios() { try { List<Object[]> scenarios = new ArrayList<>(); List<CucumberFeature> features = getFeatures(); for (CucumberFeature feature : features) { for (PickleEvent pickle : feature.getPickles()) { if (filters.matchesFilters(pickle)) { scenarios.add(new Object[]{new PickleEventWrapperImpl(pickle), new CucumberFeatureWrapperImpl(feature)}); } } } return scenarios.toArray(new Object[][]{}); } catch (CucumberException e) { return new Object[][]{new Object[]{new CucumberExceptionWrapper(e), null}}; } }
Example #4
Source File: CucumberRunner.java From bdt with Apache License 2.0 | 6 votes |
public void runScenario(PickleEvent pickle) throws Throwable { //Possibly invoked in a multi-threaded context Throwable e = null; Runner runner = runnerSupplier.get(); List<PickleEvent> pickleEventList = getPickleEventListFromTags(pickle); for (PickleEvent pickleEvent : pickleEventList) { try { TestCaseResultListener testCaseResultListener = new TestCaseResultListener(runner.getBus(), runtimeOptions.isStrict()); runner.runPickle(pickleEvent); testCaseResultListener.finishExecutionUnit(); if (!testCaseResultListener.isPassed()) { throw testCaseResultListener.getError(); } } catch (Throwable e1) { e = e1; } } if (e != null) { throw e; } }
Example #5
Source File: MandatoryAspect.java From bdt with Apache License 2.0 | 6 votes |
/** * @param pjp ProceedingJoinPoint * @param pickle pickle * @throws Throwable exception */ @Around(value = "addMandatoryPointcutScenario(pickle)") public void aroundAddMandatoryPointcut(ProceedingJoinPoint pjp, PickleEvent pickle) throws Throwable { Runner runner = (Runner) pjp.getThis(); Class<?> sc = runner.getClass(); Method tt = sc.getDeclaredMethod("buildBackendWorlds"); tt.setAccessible(true); tt.invoke(runner); String scenarioName = pickle.pickle.getName(); List<PickleTag> pickleTagList = pickle.pickle.getTags(); List<String> tagList = new ArrayList<>(); for (PickleTag pt:pickleTagList) { tagList.add(pt.getName()); } boolean exec = manageTags(tagList); if (!exec) { logger.error("Feature will not be executed. Mandatory variables not defined."); } else { pjp.proceed(); } }
Example #6
Source File: LoopConverter.java From bdt with Apache License 2.0 | 6 votes |
private static PickleEvent generatePickleEvent(String[] keys, String[] values, String uri, String name, String language, List<PickleStep> steps, List<PickleTag> tags, List<PickleLocation> locations) { List<PickleStep> newSteps = new ArrayList<>(); for (PickleStep step : steps) { String newStepText = step.getText(); List<Argument> argumentListReplaced = step.getArgument(); for (int i = 0; i < keys.length; i++) { newStepText = newStepText.replaceAll("<" + keys[i] + ">", values[i]); argumentListReplaced = replaceArguments("<" + keys[i] + ">", values[i], argumentListReplaced); } newSteps.add(new PickleStep(newStepText, argumentListReplaced, step.getLocations())); } String newScenarioname = name; for (int i = 0; i < keys.length; i++) { newScenarioname = newScenarioname.replaceAll("<" + keys[i] + ">", values[i]); } Pickle pickle = new Pickle(newScenarioname, language, newSteps, tags, locations); return new PickleEvent(uri, pickle); }
Example #7
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void or_tag_predicate_matches_pickle_with_one_of_the_tags() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_OR_BAR_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #8
Source File: IgnoreTagAspect.java From bdt with Apache License 2.0 | 5 votes |
/** * @param pjp ProceedingJoinPoint * @param pickle pickle * @throws Throwable exception */ @Around(value = "addIgnoreTagPointcutScenario(pickle)") public void aroundAddIgnoreTagPointcut(ProceedingJoinPoint pjp, PickleEvent pickle) throws Throwable { Runner runner = (Runner) pjp.getThis(); Class<?> sc = runner.getClass(); Method tt = sc.getDeclaredMethod("buildBackendWorlds"); tt.setAccessible(true); tt.invoke(runner); String scenarioName = pickle.pickle.getName(); List<PickleTag> pickleTagList = pickle.pickle.getTags(); List<String> tagList = new ArrayList<>(); for (PickleTag pt : pickleTagList) { tagList.add(pt.getName()); } ignoreReasons exitReason = manageTags(tagList, scenarioName); if (exitReason.equals(ignoreReasons.NOREASON)) { logger.error("Scenario '" + scenarioName + "' failed due to wrong use of the @ignore tag."); } if ((!(exitReason.equals(ignoreReasons.NOTIGNORED))) && (!(exitReason.equals(ignoreReasons.NOREASON)))) { tt = sc.getDeclaredMethod("disposeBackendWorlds"); tt.setAccessible(true); tt.invoke(runner); } else { pjp.proceed(); } }
Example #9
Source File: LoopConverter.java From bdt with Apache License 2.0 | 5 votes |
private static PickleEvent generatePickleEvent(String elem, int numElem, String paramReplace, String uri, String name, String language, List<PickleStep> steps, List<PickleTag> tags, List<PickleLocation> locations) { List<PickleStep> newSteps = new ArrayList<>(); for (PickleStep step : steps) { String newStepText = step.getText().replaceAll("<" + paramReplace + ">", elem).replaceAll("<" + paramReplace + ".id>", String.valueOf(numElem)); List<Argument> argumentListReplaced = replaceArguments("<" + paramReplace + ">", elem, step.getArgument()); argumentListReplaced = replaceArguments("<" + paramReplace + ".id>", elem, argumentListReplaced); newSteps.add(new PickleStep(newStepText, argumentListReplaced, step.getLocations())); } String newScenarioname = name.replaceAll("<" + paramReplace + ">", elem).replaceAll("<" + paramReplace + ".id>", String.valueOf(numElem)); Pickle pickle = new Pickle(newScenarioname, language, newSteps, tags, locations); return new PickleEvent(uri, pickle); }
Example #10
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void old_and_new_style_tag_expressions_can_be_combined() { PickleEvent pickleEvent = createPickleWithTags(asList(BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(BAR_TAG_VALUE, OLD_STYLE_NOT_FOO_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #11
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void multiple_tag_expressions_are_combined_with_and() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG, BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_TAG_VALUE, BAR_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #12
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void old_style_or_tag_predicate_is_handled() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG)); TagPredicate predicate = new TagPredicate(asList(OLD_STYLE_FOO_OR_BAR_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #13
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void old_style_not_tag_predicate_is_handled() { PickleEvent pickleEvent = createPickleWithTags(asList(BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(OLD_STYLE_NOT_FOO_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #14
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void or_tag_predicate_does_not_match_pickle_none_of_the_tags() { PickleEvent pickleEvent = createPickleWithTags(Collections.<PickleTag>emptyList()); TagPredicate predicate = new TagPredicate(asList(FOO_OR_BAR_TAG_VALUE)); assertFalse(predicate.apply(pickleEvent)); }
Example #15
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void and_tag_predicate_does_not_match_pickle_with_one_of_the_tags() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_AND_BAR_TAG_VALUE)); assertFalse(predicate.apply(pickleEvent)); }
Example #16
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void and_tag_predicate_matches_pickle_with_all_tags() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG, BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_AND_BAR_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #17
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void not_tag_predicate_matches_pickle_with_different_single_tag() { PickleEvent pickleEvent = createPickleWithTags(asList(BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(NOT_FOO_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #18
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void not_tag_predicate_does_not_match_pickle_with_same_single_tag() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG)); TagPredicate predicate = new TagPredicate(asList(NOT_FOO_TAG_VALUE)); assertFalse(predicate.apply(pickleEvent)); }
Example #19
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void not_tag_predicate_matches_pickle_with_no_tags() { PickleEvent pickleEvent = createPickleWithTags(Collections.<PickleTag>emptyList()); TagPredicate predicate = new TagPredicate(asList(NOT_FOO_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #20
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void single_tag_predicate_does_not_match_pickle_with_different_single_tag() { PickleEvent pickleEvent = createPickleWithTags(asList(BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_TAG_VALUE)); assertFalse(predicate.apply(pickleEvent)); }
Example #21
Source File: UITestRunner.java From frameworkium-bdd with Apache License 2.0 | 5 votes |
@BeforeMethod(alwaysRun = true) public void setTestName(Method method, Object[] testData) { PickleEvent pickleEvent = ((PickleEventWrapper) testData[0]).getPickleEvent(); String scenarioName = pickleEvent.pickle.getName(); this.scenarioName.set(scenarioName); logger.info("START {}", scenarioName); UITestLifecycle.get().beforeTestMethod(scenarioName); }
Example #22
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void single_tag_predicate_matches_pickle_with_more_tags() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG, BAR_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #23
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void single_tag_predicate_matches_pickle_with_same_single_tag() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG)); TagPredicate predicate = new TagPredicate(asList(FOO_TAG_VALUE)); assertTrue(predicate.apply(pickleEvent)); }
Example #24
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void single_tag_predicate_does_not_match_pickle_with_no_tags() { PickleEvent pickleEvent = createPickleWithTags(Collections.<PickleTag>emptyList()); TagPredicate predicate = new TagPredicate(asList(FOO_TAG_VALUE)); assertFalse(predicate.apply(pickleEvent)); }
Example #25
Source File: TagPredicateTest.java From cucumber-jvm-parallel-plugin with Apache License 2.0 | 5 votes |
@Test public void empty_tag_predicate_matches_pickle_with_any_tags() { PickleEvent pickleEvent = createPickleWithTags(asList(FOO_TAG)); TagPredicate predicate = new TagPredicate(null); assertTrue(predicate.apply(pickleEvent)); }
Example #26
Source File: APITestRunner.java From frameworkium-bdd with Apache License 2.0 | 5 votes |
@BeforeMethod(alwaysRun = true) public void setTestName(Method method, Object[] testData) { PickleEvent pickleEvent = ((PickleEventWrapper) testData[0]).getPickleEvent(); String scenarioName = pickleEvent.pickle.getName(); this.scenarioName.set(scenarioName); logger.info("START {}", scenarioName); }
Example #27
Source File: IgnoreTagAspect.java From bdt with Apache License 2.0 | 4 votes |
@Pointcut("execution (* cucumber.runner.Runner.runPickle(..)) && " + "args (pickle)") protected void addIgnoreTagPointcutScenario(PickleEvent pickle) { }
Example #28
Source File: MandatoryAspect.java From bdt with Apache License 2.0 | 4 votes |
@Pointcut("execution (* cucumber.runner.Runner.runPickle(..)) && " + "args (pickle)") protected void addMandatoryPointcutScenario(PickleEvent pickle) { }
Example #29
Source File: RunOnTagAspect.java From bdt with Apache License 2.0 | 4 votes |
@Pointcut("execution (* cucumber.runner.Runner.runPickle(..)) && " + "args (pickleEvent)") protected void AddRunOnTagPointcutScenario(PickleEvent pickleEvent) { }
Example #30
Source File: ReplacementAspect.java From bdt with Apache License 2.0 | 4 votes |
@Pointcut("execution (* cucumber.runner.Runner.runPickle(..)) && " + "args (pickle)") protected void replacementScenarios(PickleEvent pickle) { }