cucumber.api.TestCase Java Examples
The following examples show how to use
cucumber.api.TestCase.
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: ExtentCucumberAdapter.java From extentreports-cucumber4-adapter with Apache License 2.0 | 6 votes |
private synchronized void createFeature(TestCase testCase) { Feature feature = testSources.getFeature(testCase.getUri()); if (feature != null) { if (featureMap.containsKey(feature.getName())) { featureTestThreadLocal.set(featureMap.get(feature.getName())); return; } if (featureTestThreadLocal.get() != null && featureTestThreadLocal.get().getModel().getName().equals(feature.getName())) { return; } ExtentTest t = ExtentService.getInstance() .createTest(com.aventstack.extentreports.gherkin.model.Feature.class, feature.getName(), feature.getDescription()); featureTestThreadLocal.set(t); featureMap.put(feature.getName(), t); List<String> tagList = createTagsList(feature.getTags()); tagList.forEach(featureTestThreadLocal.get()::assignCategory); } }
Example #2
Source File: ExtentCucumberAdapter.java From extentreports-cucumber4-adapter with Apache License 2.0 | 6 votes |
private synchronized void handleScenarioOutline(TestCase testCase) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile.get(), testCase.getLine()); if (TestSourcesModel.isScenarioOutlineScenario(astNode)) { ScenarioOutline scenarioOutline = (ScenarioOutline)TestSourcesModel.getScenarioDefinition(astNode); if (currentScenarioOutline.get() == null || !currentScenarioOutline.get().getName().equals(scenarioOutline.getName())) { scenarioOutlineThreadLocal.set(null); createScenarioOutline(scenarioOutline); currentScenarioOutline.set(scenarioOutline); addOutlineStepsToReport(scenarioOutline); } Examples examples = (Examples)astNode.parent.node; if (currentExamples.get() == null || !currentExamples.get().equals(examples)) { currentExamples.set(examples); createExamples(examples); } } else { scenarioOutlineThreadLocal.set(null); currentScenarioOutline.set(null); currentExamples.set(null); } }
Example #3
Source File: CukesGHooks.java From bdt with Apache License 2.0 | 5 votes |
public String calculateElementName(cucumber.api.TestCase testCase) { String testCaseName = testCase.getName(); if (testCaseName.equals(previousTestCaseName)) { exampleNumber++; ThreadProperty.set("dataSet", String.valueOf(exampleNumber)); return Utils.getUniqueTestNameForScenarioExample(testCaseName, exampleNumber); } else { ThreadProperty.set("dataSet", ""); previousTestCaseName = testCase.getName(); exampleNumber = 1; return testCaseName; } }
Example #4
Source File: CukesGHooks.java From bdt with Apache License 2.0 | 5 votes |
private void handleTestCaseStarted(TestCaseStarted event) { if (currentFeatureFile == null || !currentFeatureFile.equals(event.testCase.getUri())) { currentFeatureFile = event.testCase.getUri(); } TestCase tc = event.testCase; logger.info("Feature/Scenario: {}/{} ", TestSourcesModelUtil.INSTANCE.getTestSourcesModel().getFeatureName(currentFeatureFile), tc.getName()); ThreadProperty.set("feature", TestSourcesModelUtil.INSTANCE.getTestSourcesModel().getFeatureName(currentFeatureFile)); ThreadProperty.set("scenario", calculateElementName(tc)); }
Example #5
Source File: CucumberReporter.java From bdt with Apache License 2.0 | 5 votes |
public String calculateElementName(cucumber.api.TestCase testCase) { String testCaseName = testCase.getName(); if (testCaseName.equals(previousTestCaseName)) { exampleNumber++; ThreadProperty.set("dataSet", String.valueOf(exampleNumber)); return Utils.getUniqueTestNameForScenarioExample(testCaseName, exampleNumber); } else { ThreadProperty.set("dataSet", ""); previousTestCaseName = testCase.getName(); exampleNumber = 1; return testCaseName; } }
Example #6
Source File: ExtentCucumberAdapter.java From extentreports-cucumber4-adapter with Apache License 2.0 | 5 votes |
private synchronized void createTestCase(TestCase testCase) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile.get(), testCase.getLine()); if (astNode != null) { ScenarioDefinition scenarioDefinition = TestSourcesModel.getScenarioDefinition(astNode); ExtentTest parent = scenarioOutlineThreadLocal.get() != null ? scenarioOutlineThreadLocal.get() : featureTestThreadLocal.get(); ExtentTest t = parent.createNode(com.aventstack.extentreports.gherkin.model.Scenario.class, scenarioDefinition.getName(), scenarioDefinition.getDescription()); scenarioThreadLocal.set(t); } if (!testCase.getTags().isEmpty()) { testCase.getTags() .stream() .map(PickleTag::getName) .forEach(scenarioThreadLocal.get()::assignCategory); } }
Example #7
Source File: AllureCucumber2Jvm.java From allure-java with Apache License 2.0 | 4 votes |
private String getHistoryId(final TestCase testCase) { final String testCaseLocation = testCase.getUri() + ":" + testCase.getLine(); return md5(testCaseLocation); }
Example #8
Source File: TagParser.java From allure-java with Apache License 2.0 | 4 votes |
TagParser(final Feature feature, final TestCase scenario) { this.feature = feature; this.scenario = scenario; }
Example #9
Source File: LabelBuilder.java From allure-java with Apache License 2.0 | 4 votes |
LabelBuilder(final Feature feature, final TestCase scenario, final Deque<PickleTag> tags) { final TagParser tagParser = new TagParser(feature, scenario); getScenarioLabels().add(createFeatureLabel(feature.getName())); getScenarioLabels().add(createStoryLabel(scenario.getName())); while (tags.peek() != null) { final PickleTag tag = tags.remove(); final String tagString = tag.getName(); if (tagString.contains(COMPOSITE_TAG_DELIMITER)) { final String[] tagParts = tagString.split(COMPOSITE_TAG_DELIMITER, 2); if (tagParts.length < 2 || Objects.isNull(tagParts[1]) || tagParts[1].isEmpty()) { // skip empty tags, e.g. '@tmsLink=', to avoid formatter errors continue; } final String tagKey = tagParts[0].toUpperCase(); final String tagValue = tagParts[1]; // Handle composite named links if (tagKey.startsWith(PLAIN_LINK + ".")) { tryHandleNamedLink(tagString); continue; } switch (tagKey) { case SEVERITY: getScenarioLabels().add(createSeverityLabel(tagValue.toLowerCase())); break; case TMS_LINK: getScenarioLinks().add(createTmsLink(tagValue)); break; case ISSUE_LINK: getScenarioLinks().add(createIssueLink(tagValue)); break; case PLAIN_LINK: getScenarioLinks().add(createLink(null, tagValue, tagValue, null)); break; default: LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey); getScenarioLabels().add(getTagLabel(tag)); break; } } else if (tagParser.isPureSeverityTag(tag)) { getScenarioLabels().add(createSeverityLabel(tagString.substring(1))); } else if (!tagParser.isResultTag(tag)) { getScenarioLabels().add(getTagLabel(tag)); } } getScenarioLabels().addAll(Arrays.asList( createHostLabel(), createThreadLabel(), createPackageLabel(feature.getName()), createSuiteLabel(feature.getName()), createTestClassLabel(scenario.getName()), createFrameworkLabel("cucumber2jvm"), createLanguageLabel("java") )); }
Example #10
Source File: AllureCucumber4Jvm.java From allure-java with Apache License 2.0 | 4 votes |
private String getTestCaseUuid(final TestCase testCase) { return scenarioUuids.computeIfAbsent(getHistoryId(testCase), it -> UUID.randomUUID().toString()); }
Example #11
Source File: AllureCucumber4Jvm.java From allure-java with Apache License 2.0 | 4 votes |
private String getHistoryId(final TestCase testCase) { final String testCaseLocation = testCase.getUri() + ":" + testCase.getLine(); return md5(testCaseLocation); }
Example #12
Source File: TagParser.java From allure-java with Apache License 2.0 | 4 votes |
TagParser(final Feature feature, final TestCase scenario) { this.feature = feature; this.scenario = scenario; }
Example #13
Source File: LabelBuilder.java From allure-java with Apache License 2.0 | 4 votes |
LabelBuilder(final Feature feature, final TestCase scenario, final Deque<PickleTag> tags) { final TagParser tagParser = new TagParser(feature, scenario); while (tags.peek() != null) { final PickleTag tag = tags.remove(); final String tagString = tag.getName(); if (tagString.contains(COMPOSITE_TAG_DELIMITER)) { final String[] tagParts = tagString.split(COMPOSITE_TAG_DELIMITER, 2); if (tagParts.length < 2 || Objects.isNull(tagParts[1]) || tagParts[1].isEmpty()) { // skip empty tags, e.g. '@tmsLink=', to avoid formatter errors continue; } final String tagKey = tagParts[0].toUpperCase(); final String tagValue = tagParts[1]; // Handle composite named links if (tagKey.startsWith(PLAIN_LINK + ".")) { tryHandleNamedLink(tagString); continue; } switch (tagKey) { case SEVERITY: getScenarioLabels().add(ResultsUtils.createSeverityLabel(tagValue.toLowerCase())); break; case TMS_LINK: getScenarioLinks().add(ResultsUtils.createTmsLink(tagValue)); break; case ISSUE_LINK: getScenarioLinks().add(ResultsUtils.createIssueLink(tagValue)); break; case PLAIN_LINK: getScenarioLinks().add(ResultsUtils.createLink(null, tagValue, tagValue, null)); break; default: LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey); getScenarioLabels().add(getTagLabel(tag)); break; } } else if (tagParser.isPureSeverityTag(tag)) { getScenarioLabels().add(ResultsUtils.createSeverityLabel(tagString.substring(1))); } else if (!tagParser.isResultTag(tag)) { getScenarioLabels().add(getTagLabel(tag)); } } final String featureName = feature.getName(); final String uri = scenario.getUri(); getScenarioLabels().addAll(Arrays.asList( createHostLabel(), createThreadLabel(), createFeatureLabel(featureName), createStoryLabel(scenario.getName()), createSuiteLabel(featureName), createTestClassLabel(scenario.getName()), createFrameworkLabel("cucumber4jvm"), createLanguageLabel("java"), createLabel("gherkin_uri", uri) )); featurePackage(uri, featureName) .map(ResultsUtils::createPackageLabel) .ifPresent(getScenarioLabels()::add); }
Example #14
Source File: AllureCucumber3Jvm.java From allure-java with Apache License 2.0 | 4 votes |
private String getTestCaseUuid(final TestCase testCase) { return scenarioUuids.computeIfAbsent(getHistoryId(testCase), it -> UUID.randomUUID().toString()); }
Example #15
Source File: AllureCucumber3Jvm.java From allure-java with Apache License 2.0 | 4 votes |
private String getHistoryId(final TestCase testCase) { final String testCaseLocation = testCase.getUri() + ":" + testCase.getLine(); return md5(testCaseLocation); }
Example #16
Source File: TagParser.java From allure-java with Apache License 2.0 | 4 votes |
TagParser(final Feature feature, final TestCase scenario) { this.feature = feature; this.scenario = scenario; }
Example #17
Source File: LabelBuilder.java From allure-java with Apache License 2.0 | 4 votes |
LabelBuilder(final Feature feature, final TestCase scenario, final Deque<PickleTag> tags) { final TagParser tagParser = new TagParser(feature, scenario); getScenarioLabels().add(createFeatureLabel(feature.getName())); getScenarioLabels().add(createStoryLabel(scenario.getName())); while (tags.peek() != null) { final PickleTag tag = tags.remove(); final String tagString = tag.getName(); if (tagString.contains(COMPOSITE_TAG_DELIMITER)) { final String[] tagParts = tagString.split(COMPOSITE_TAG_DELIMITER, 2); if (tagParts.length < 2 || Objects.isNull(tagParts[1]) || tagParts[1].isEmpty()) { // skip empty tags, e.g. '@tmsLink=', to avoid formatter errors continue; } final String tagKey = tagParts[0].toUpperCase(); final String tagValue = tagParts[1]; // Handle composite named links if (tagKey.startsWith(PLAIN_LINK + ".")) { tryHandleNamedLink(tagString); continue; } switch (tagKey) { case SEVERITY: getScenarioLabels().add(createSeverityLabel(tagValue.toLowerCase())); break; case TMS_LINK: getScenarioLinks().add(createTmsLink(tagValue)); break; case ISSUE_LINK: getScenarioLinks().add(createIssueLink(tagValue)); break; case PLAIN_LINK: getScenarioLinks().add(createLink(null, tagValue, tagValue, null)); break; default: LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey); getScenarioLabels().add(getTagLabel(tag)); break; } } else if (tagParser.isPureSeverityTag(tag)) { getScenarioLabels().add(createSeverityLabel(tagString.substring(1))); } else if (!tagParser.isResultTag(tag)) { getScenarioLabels().add(getTagLabel(tag)); } } getScenarioLabels().addAll(Arrays.asList( createHostLabel(), createThreadLabel(), createPackageLabel(feature.getName()), createSuiteLabel(feature.getName()), createTestClassLabel(scenario.getName()), createFrameworkLabel("cucumber3jvm"), createLanguageLabel("java") )); }
Example #18
Source File: CucumberReporter.java From bdt with Apache License 2.0 | 4 votes |
public TestMethod(TestCase scenario) { this.scenario = scenario; }
Example #19
Source File: AllureCucumber2Jvm.java From allure-java with Apache License 2.0 | 4 votes |
private String getTestCaseUuid(final TestCase testCase) { return scenarioUuids.computeIfAbsent(getHistoryId(testCase), it -> UUID.randomUUID().toString()); }
Example #20
Source File: ExtentCucumberAdapter.java From extentreports-cucumber4-adapter with Apache License 2.0 | 4 votes |
private synchronized void handleStartOfFeature(TestCase testCase) { if (currentFeatureFile == null || !currentFeatureFile.equals(testCase.getUri())) { currentFeatureFile.set(testCase.getUri()); createFeature(testCase); } }