diff --git a/pom.xml b/pom.xml index 019f4ee..2e3d234 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ io.cucumber.zephyr 1.8 4.13 - 4.2.0 + 6.11.0 diff --git a/src/main/java/io/cucumber/zephyr/TestSourcesModel.java b/src/main/java/io/cucumber/zephyr/TestSourcesModel.java index 7148aad..0050e1a 100644 --- a/src/main/java/io/cucumber/zephyr/TestSourcesModel.java +++ b/src/main/java/io/cucumber/zephyr/TestSourcesModel.java @@ -1,24 +1,31 @@ package io.cucumber.zephyr; -import cucumber.api.event.TestSourceRead; -import gherkin.AstBuilder; -import gherkin.GherkinDialect; -import gherkin.GherkinDialectProvider; -import gherkin.Parser; -import gherkin.ParserException; -import gherkin.TokenMatcher; -import gherkin.ast.Background; -import gherkin.ast.Examples; -import gherkin.ast.Feature; -import gherkin.ast.GherkinDocument; -import gherkin.ast.Node; -import gherkin.ast.ScenarioDefinition; -import gherkin.ast.ScenarioOutline; -import gherkin.ast.Step; -import gherkin.ast.TableRow; +import io.cucumber.gherkin.Gherkin; +import io.cucumber.gherkin.GherkinDialect; +import io.cucumber.gherkin.GherkinDialectProvider; +import io.cucumber.messages.Messages; +import io.cucumber.messages.Messages.GherkinDocument; +import io.cucumber.messages.Messages.GherkinDocument.Feature; +import io.cucumber.messages.Messages.GherkinDocument.Feature.Background; +import io.cucumber.messages.Messages.GherkinDocument.Feature.FeatureChild; +import io.cucumber.messages.Messages.GherkinDocument.Feature.FeatureChild.RuleChild; +import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; +import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario.Examples; +import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; +import io.cucumber.messages.Messages.GherkinDocument.Feature.TableRow; +import io.cucumber.messages.internal.com.google.protobuf.GeneratedMessageV3; +import io.cucumber.messages.internal.com.google.protobuf.Message; +import io.cucumber.plugin.event.TestSourceRead; +import java.net.URI; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.UUID; + +import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; +import static java.util.Collections.singletonList; +import static java.util.stream.Collectors.toList; final class TestSourcesModel { private final Map pathToReadEventMap = new HashMap(); @@ -34,36 +41,24 @@ static Feature getFeatureForTestCase(AstNode astNode) { static Background getBackgroundForTestCase(AstNode astNode) { Feature feature = getFeatureForTestCase(astNode); - ScenarioDefinition backgound = feature.getChildren().get(0); - if (backgound instanceof Background) { - return (Background) backgound; - } else { - return null; - } - } - - static ScenarioDefinition getScenarioDefinition(AstNode astNode) { - return astNode.node instanceof ScenarioDefinition ? (ScenarioDefinition) astNode.node : (ScenarioDefinition) astNode.parent.parent.node; - } - - static boolean isScenarioOutlineScenario(AstNode astNode) { - return !(astNode.node instanceof ScenarioDefinition); - } - - static boolean isBackgroundStep(AstNode astNode) { - return astNode.parent.node instanceof Background; + return feature.getChildrenList() + .stream() + .filter(FeatureChild::hasBackground) + .map(FeatureChild::getBackground) + .findFirst() + .orElse(null); } static String calculateId(AstNode astNode) { - Node node = astNode.node; - if (node instanceof ScenarioDefinition) { - return calculateId(astNode.parent) + ";" + convertToId(((ScenarioDefinition) node).getName()); + GeneratedMessageV3 node = astNode.node; + if (node instanceof Scenario) { + return calculateId(astNode.parent) + ";" + convertToId(((Scenario) node).getName()); } if (node instanceof ExamplesRowWrapperNode) { - return calculateId(astNode.parent) + ";" + Integer.toString(((ExamplesRowWrapperNode) node).bodyRowIndex + 2); + return calculateId(astNode.parent) + ";" + (((ExamplesRowWrapperNode) node).bodyRowIndex + 2); } if (node instanceof TableRow) { - return calculateId(astNode.parent) + ";" + Integer.toString(1); + return calculateId(astNode.parent) + ";" + 1; } if (node instanceof Examples) { return calculateId(astNode.parent) + ";" + convertToId(((Examples) node).getName()); @@ -74,15 +69,15 @@ static String calculateId(AstNode astNode) { return ""; } - static String convertToId(String name) { + static String convertToId (String name){ return name.replaceAll("[\\s'_,!]", "-").toLowerCase(); } - void addTestSourceReadEvent(String path, TestSourceRead event) { + void addTestSourceReadEvent (String path, TestSourceRead event){ pathToReadEventMap.put(path, event); } - Feature getFeature(String path) { + Feature getFeature (String path){ if (!pathToAstMap.containsKey(path)) { parseGherkinSource(path); } @@ -92,11 +87,7 @@ Feature getFeature(String path) { return null; } - ScenarioDefinition getScenarioDefinition(String path, int line) { - return getScenarioDefinition(getAstNode(path, line)); - } - - AstNode getAstNode(String path, int line) { + AstNode getAstNode (String path,int line){ if (!pathToNodeMap.containsKey(path)) { parseGherkinSource(path); } @@ -106,7 +97,7 @@ AstNode getAstNode(String path, int line) { return null; } - boolean hasBackground(String path, int line) { + boolean hasBackground (String path,int line){ if (!pathToNodeMap.containsKey(path)) { parseGherkinSource(path); } @@ -121,7 +112,7 @@ String getKeywordFromSource(String uri, int stepLine) { Feature feature = getFeature(uri); if (feature != null) { TestSourceRead event = getTestSourceReadEvent(uri); - String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim(); + String trimmedSourceLine = event.getSource().split("\n")[stepLine - 1].trim(); GherkinDialect dialect = new GherkinDialectProvider(feature.getLanguage()).getDefaultDialect(); for (String keyword : dialect.getStepKeywords()) { if (trimmedSourceLine.startsWith(keyword)) { @@ -132,14 +123,14 @@ String getKeywordFromSource(String uri, int stepLine) { return ""; } - private TestSourceRead getTestSourceReadEvent(String uri) { + private TestSourceRead getTestSourceReadEvent (String uri){ if (pathToReadEventMap.containsKey(uri)) { return pathToReadEventMap.get(uri); } return null; } - String getFeatureName(String uri) { + String getFeatureName (String uri){ Feature feature = getFeature(uri); if (feature != null) { return feature.getName(); @@ -151,64 +142,137 @@ private void parseGherkinSource(String path) { if (!pathToReadEventMap.containsKey(path)) { return; } - Parser parser = new Parser(new AstBuilder()); - TokenMatcher matcher = new TokenMatcher(); - try { - GherkinDocument gherkinDocument = parser.parse(pathToReadEventMap.get(path).source, matcher); - pathToAstMap.put(path, gherkinDocument); - Map nodeMap = new HashMap(); - AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null); - for (ScenarioDefinition child : gherkinDocument.getFeature().getChildren()) { - processScenarioDefinition(nodeMap, child, currentParent); + String source = pathToReadEventMap.get(path).getSource(); + + List sources = singletonList( + makeSourceEnvelope(source, path)); + + List envelopes = Gherkin.fromSources( + sources, + true, + true, + true, + () -> String.valueOf(UUID.randomUUID())).collect(toList()); + + GherkinDocument gherkinDocument = envelopes.stream() + .filter(Messages.Envelope::hasGherkinDocument) + .map(Messages.Envelope::getGherkinDocument) + .findFirst() + .orElse(null); + + pathToAstMap.put(String.valueOf(path), gherkinDocument); + Map nodeMap = new HashMap<>(); + AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null); + for (FeatureChild child : gherkinDocument.getFeature().getChildrenList()) { + processFeatureDefinition(nodeMap, child, currentParent); + } + pathToNodeMap.put(path, nodeMap); + + } + + private void processFeatureDefinition(Map nodeMap, FeatureChild child, AstNode currentParent) { + if (child.hasBackground()) { + processBackgroundDefinition(nodeMap, child.getBackground(), currentParent); + } else if (child.hasScenario()) { + processScenarioDefinition(nodeMap, child.getScenario(), currentParent); + } else if (child.hasRule()) { + AstNode childNode = new AstNode(child.getRule(), currentParent); + nodeMap.put(child.getRule().getLocation().getLine(), childNode); + for (RuleChild ruleChild : child.getRule().getChildrenList()) { + processRuleDefinition(nodeMap, ruleChild, childNode); } - pathToNodeMap.put(path, nodeMap); - } catch (ParserException e) { - // Ignore exceptions } } - private void processScenarioDefinition(Map nodeMap, ScenarioDefinition child, AstNode currentParent) { + private void processBackgroundDefinition( + Map nodeMap, Background background, AstNode currentParent + ) { + AstNode childNode = new AstNode(background, currentParent); + nodeMap.put(background.getLocation().getLine(), childNode); + for (Step step : background.getStepsList()) { + nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode)); + } + } + + private void processScenarioDefinition(Map nodeMap, Scenario child, AstNode currentParent) { AstNode childNode = new AstNode(child, currentParent); nodeMap.put(child.getLocation().getLine(), childNode); - for (Step step : child.getSteps()) { + for (Step step : child.getStepsList()) { nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode)); } - if (child instanceof ScenarioOutline) { - processScenarioOutlineExamples(nodeMap, (ScenarioOutline) child, childNode); + if (child.getExamplesCount() > 0) { + processScenarioOutlineExamples(nodeMap, child, childNode); + } + } + + private void processRuleDefinition(Map nodeMap, RuleChild child, AstNode currentParent) { + if (child.hasBackground()) { + processBackgroundDefinition(nodeMap, child.getBackground(), currentParent); + } else if (child.hasScenario()) { + processScenarioDefinition(nodeMap, child.getScenario(), currentParent); } } - private void processScenarioOutlineExamples(Map nodeMap, ScenarioOutline scenarioOutline, AstNode childNode) { - for (Examples examples : scenarioOutline.getExamples()) { - AstNode examplesNode = new AstNode(examples, childNode); + private void processScenarioOutlineExamples( + Map nodeMap, Scenario scenarioOutline, AstNode parent + ) { + for (Examples examples : scenarioOutline.getExamplesList()) { + AstNode examplesNode = new AstNode(examples, parent); TableRow headerRow = examples.getTableHeader(); - AstNode headerNode = new AstNode(headerRow, examplesNode); + TestSourcesModel.AstNode headerNode = new AstNode(headerRow, examplesNode); nodeMap.put(headerRow.getLocation().getLine(), headerNode); - for (int i = 0; i < examples.getTableBody().size(); ++i) { - TableRow examplesRow = examples.getTableBody().get(i); - Node rowNode = new ExamplesRowWrapperNode(examplesRow, i); + for (int i = 0; i < examples.getTableBodyCount(); ++i) { + TableRow examplesRow = examples.getTableBody(i); + GeneratedMessageV3 rowNode = new ExamplesRowWrapperNode(examplesRow, i); AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode); nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode); } } } - class ExamplesRowWrapperNode extends Node { + class ExamplesRowWrapperNode extends GeneratedMessageV3 { + final int bodyRowIndex; - ExamplesRowWrapperNode(Node examplesRow, int bodyRowIndex) { - super(examplesRow.getLocation()); + ExamplesRowWrapperNode(GeneratedMessageV3 examplesRow, int bodyRowIndex) { this.bodyRowIndex = bodyRowIndex; } + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + protected Message.Builder newBuilderForType(BuilderParent builderParent) { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public Message.Builder newBuilderForType() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public Message.Builder toBuilder() { + throw new UnsupportedOperationException("not implemented"); + } + + @Override + public Message getDefaultInstanceForType() { + throw new UnsupportedOperationException("not implemented"); + } + } class AstNode { - final Node node; + final GeneratedMessageV3 node; final AstNode parent; - AstNode(Node node, AstNode parent) { + AstNode(GeneratedMessageV3 node, AstNode parent) { this.node = node; this.parent = parent; } } + } diff --git a/src/main/java/io/cucumber/zephyr/URLOutputStream.java b/src/main/java/io/cucumber/zephyr/URLOutputStream.java new file mode 100644 index 0000000..5610915 --- /dev/null +++ b/src/main/java/io/cucumber/zephyr/URLOutputStream.java @@ -0,0 +1,69 @@ +package io.cucumber.zephyr; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.Collections; +import java.util.Map; + +public class URLOutputStream extends OutputStream { + private final URL url; + private final String method; + private final int expectedResponseCode; + private final OutputStream out; + private final HttpURLConnection urlConnection; + + public URLOutputStream(URL url) throws IOException { + this(url, "PUT", Collections.emptyMap(), 200); + } + public URLOutputStream(URL url, String method, Map headers, int expectedResponseCode) throws IOException { + this.url = url; + this.method = method; + this.expectedResponseCode = expectedResponseCode; + if (url.getProtocol().equals("file")) { + File file = new File(url.getFile()); + ensureParentDirExists(file); + out = new FileOutputStream(file); + urlConnection = null; + } else if (url.getProtocol().startsWith("http")) { + urlConnection = (HttpURLConnection) url.openConnection(); + urlConnection.setRequestMethod(method); + urlConnection.setDoOutput(true); + for (Map.Entry header : headers.entrySet()) { + urlConnection.setRequestProperty(header.getKey(), header.getValue()); + } + out = urlConnection.getOutputStream(); + } else { + throw new IllegalArgumentException("URL Scheme must be one of file,http,https. " + url.toExternalForm()); + } + } + + private void ensureParentDirExists(File file) throws IOException { + if (file.getParentFile() != null && !file.getParentFile().isDirectory()) { + boolean ok = file.getParentFile().mkdirs() || file.getParentFile().isDirectory(); + if (!ok) { + throw new IOException("Failed to create directory " + file.getParentFile().getAbsolutePath()); + } + } + } + + @Override + public void write(byte[] buffer, int offset, int count) throws IOException { + out.write(buffer, offset, count); + } + + @Override + public void write(byte[] buffer) throws IOException { + out.write(buffer); + } + + @Override + public void write(int b) throws IOException { + out.write(b); + } + + @Override + public void flush() throws IOException { + out.flush(); + } +} diff --git a/src/main/java/io/cucumber/zephyr/Utils.java b/src/main/java/io/cucumber/zephyr/Utils.java new file mode 100644 index 0000000..2569e54 --- /dev/null +++ b/src/main/java/io/cucumber/zephyr/Utils.java @@ -0,0 +1,7 @@ +package io.cucumber.zephyr; + +public class Utils { + public static String getUniqueTestNameForScenarioExample(String testCaseName, int exampleNumber) { + return testCaseName + (testCaseName.contains(" ") ? " " : "_") + exampleNumber; + } +} diff --git a/src/main/java/io/cucumber/zephyr/ZephyrXMLFormatter.java b/src/main/java/io/cucumber/zephyr/ZephyrXMLFormatter.java index 9766ddd..9c5e572 100644 --- a/src/main/java/io/cucumber/zephyr/ZephyrXMLFormatter.java +++ b/src/main/java/io/cucumber/zephyr/ZephyrXMLFormatter.java @@ -1,21 +1,9 @@ package io.cucumber.zephyr; -import cucumber.api.PickleStepTestStep; -import cucumber.api.Result; -import cucumber.api.event.EventHandler; -import cucumber.api.event.EventListener; -import cucumber.api.event.EventPublisher; -import cucumber.api.event.TestCaseFinished; -import cucumber.api.event.TestCaseStarted; -import cucumber.api.event.TestRunFinished; -import cucumber.api.event.TestSourceRead; -import cucumber.api.event.TestStepFinished; -import cucumber.api.formatter.StrictAware; -import cucumber.runtime.CucumberException; -import cucumber.runtime.Utils; -import cucumber.runtime.io.URLOutputStream; -import cucumber.runtime.io.UTF8OutputStreamWriter; -import gherkin.pickles.PickleTag; +import java.io.OutputStreamWriter; +import io.cucumber.core.exception.CucumberException; +import io.cucumber.plugin.EventListener; +import io.cucumber.plugin.event.*; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -41,7 +29,9 @@ import java.util.Locale; import java.util.stream.Collectors; -public final class ZephyrXMLFormatter implements EventListener, StrictAware { +import static java.util.Locale.ROOT; + +public final class ZephyrXMLFormatter implements EventListener { private final Writer out; private final Document doc; private final Element rootElement; @@ -81,8 +71,7 @@ public void receive(TestRunFinished event) { }; public ZephyrXMLFormatter(URL out) throws IOException { - this.out = new UTF8OutputStreamWriter(new URLOutputStream(out)); - TestCase.treatConditionallySkippedAsFailure = false; + this.out = new OutputStreamWriter(new URLOutputStream(out)); TestCase.currentFeatureFile = null; TestCase.previousTestCaseName = ""; TestCase.exampleNumber = 1; @@ -105,44 +94,41 @@ public void setEventPublisher(EventPublisher publisher) { } private void handleTestSourceRead(TestSourceRead event) { - TestCase.testSources.addTestSourceReadEvent(event.uri, event); + TestCase.testSources.addTestSourceReadEvent(String.valueOf(event.getUri()), event); } private void handleTestCaseStarted(TestCaseStarted event) { - if (TestCase.currentFeatureFile == null || !TestCase.currentFeatureFile.equals(event.testCase.getUri())) { - TestCase.currentFeatureFile = event.testCase.getUri(); + if (TestCase.currentFeatureFile == null || !TestCase.currentFeatureFile.equals(event.getTestCase().getUri())) { + TestCase.currentFeatureFile = String.valueOf(event.getTestCase().getUri()); TestCase.previousTestCaseName = ""; TestCase.exampleNumber = 1; } - testCase = new TestCase(event.testCase); + testCase = new TestCase(event.getTestCase()); root = testCase.createElement(doc); testCase.writeElement(doc, root); rootElement.appendChild(root); - increaseAttributeValue(rootElement, "tests"); } private void handleTestStepFinished(TestStepFinished event) { - if (event.testStep instanceof PickleStepTestStep) { - testCase.steps.add((PickleStepTestStep) event.testStep); - testCase.results.add(event.result); + if (event.getTestStep() instanceof PickleStepTestStep) { + testCase.steps.add((PickleStepTestStep) event.getTestStep()); + testCase.results.add(event.getResult()); } } private void handleTestCaseFinished(TestCaseFinished event) { - List tags = event.testCase.getTags(); + List tags = event.getTestCase().getTags(); List requirementIds = tags .stream() - .map(PickleTag::getName) .filter(tagName -> tagName.startsWith("@JIRA_")) .map(tagName -> tagName.replaceAll("^@JIRA_", "AltID_")) .collect(Collectors.toList()); List customTags = tags .stream() - .map(PickleTag::getName) .filter(tagName -> !tagName.startsWith("@JIRA_")) .map(tagName -> tagName.replaceAll("^@", "")) .collect(Collectors.toList()); @@ -151,9 +137,9 @@ private void handleTestCaseFinished(TestCaseFinished event) { testCase.addListToElement(doc, root, "tags", "tag", customTags); if (testCase.steps.isEmpty()) { - testCase.handleEmptyTestCase(doc, root, event.result); + testCase.handleEmptyTestCase(doc, root, event.getResult()); } else { - testCase.addTestCaseElement(doc, root, event.result, requirementIds); + testCase.addTestCaseElement(doc, root, event.getResult(), requirementIds); } } @@ -201,12 +187,6 @@ private void increaseAttributeValue(Element element, String attribute) { } element.setAttribute(attribute, String.valueOf(++value)); } - - @Override - public void setStrict(boolean strict) { - TestCase.treatConditionallySkippedAsFailure = strict; - } - private static class TestCase { private static final DecimalFormat NUMBER_FORMAT = (DecimalFormat) NumberFormat.getNumberInstance(Locale.US); private static final TestSourcesModel testSources = new TestSourcesModel(); @@ -215,17 +195,16 @@ private static class TestCase { NUMBER_FORMAT.applyPattern("0.######"); } - private TestCase(cucumber.api.TestCase testCase) { + private TestCase(io.cucumber.plugin.event.TestCase testCase) { this.testCase = testCase; } static String currentFeatureFile; static String previousTestCaseName; static int exampleNumber; - static boolean treatConditionallySkippedAsFailure = false; final List steps = new ArrayList(); final List results = new ArrayList(); - private final cucumber.api.TestCase testCase; + private final io.cucumber.plugin.event.TestCase testCase; private Element createElement(Document doc) { return doc.createElement("testcase"); @@ -236,7 +215,7 @@ private void writeElement(Document doc, Element tc) { tc.setAttribute("name", calculateElementName(testCase)); } - private String calculateElementName(cucumber.api.TestCase testCase) { + private String calculateElementName(io.cucumber.plugin.event.TestCase testCase) { String testCaseName = testCase.getName(); if (testCaseName.equals(previousTestCaseName)) { return Utils.getUniqueTestNameForScenarioExample(testCaseName, ++exampleNumber); @@ -254,21 +233,17 @@ public void addTestCaseElement(Document doc, Element tc, Result result, List Customization\"") + public void Navigate_to_(){ + System.out.println("given_Admin"); + } + + @And("Click on Estimated Time Button") + public void and_test(){ + System.out.println("and_Admin"); + } + + @When("User Click on reset Estimated Time Button") + public void userClickOnResetEstimatedTimeButton() { + + } + + @And("User click on save button on {string} window") + public void userClickOnSaveButtonOnWindow(String arg0) { + + } + + @And("User click on {string} button on {string} window") + public void userClickOnButtonOnWindow(String arg0, String arg1) { + + } + + @Then("User view the default estimated time as {string}") + public void userViewTheDefaultEstimatedTimeAs(String arg0) { + } + + @Given("Navigate to \"Administration -> Project Setup\"") + public void navigateTo() { + } + + @When("User click on Add Project button") + public void userClickOnAddProjectButton() { + + } + + @And("User enters project name {string} and startdate {string}") + public void userEntersProjectNameAndStartdate(String arg0, String arg1) { + + } + + @And("User selects project type as {string}") + public void userSelectsProjectTypeAs(String arg0) { + + } + + @And("User click on Add button") + public void userClickOnAddButton() { + + } + + @Then("Project should be created successfully with project name {string} and project type {string}") + public void projectShouldBeCreatedSuccessfullyWithProjectNameAndProjectType(String arg0, String arg1) { + } + + @And("User clicks on Indexing Button") + public void userClicksOnIndexingButton() { + + } + + @And("User click on Full Reindexing button on Indexing window") + public void userClickOnFullReindexingButtonOnIndexingWindow() { + + } + + @When("User select {string} entity from Select Entities to reindex dropdown") + public void userSelectEntityFromSelectEntitiesToReindexDropdown(String arg0) { + + } + + @And("User click on Reindex button") + public void userClickOnReindexButton() { + + } + + @Then("User verify job in indexing grid for {string} entity with {string} status") + public void userVerifyJobInIndexingGridForEntityWithStatus(String arg0, String arg1) { + + } + + @Given("User navigates to Requirement App") + public void userNavigatesToRequirementApp() { + + } + + @And("User navigates to {string}") + public void userNavigatesTo(String arg0) { + + } + + @Then("Folder {string} with Requirement should be deleted successfully") + public void folderWithRequirementShouldBeDeletedSuccessfully(String arg0) { + + } + + @And("User click on {string} Button") + public void userClickOnButton(String arg0) { + + } + + @When("User context click on folder {string}") + public void userContextClickOnFolder(String arg0) { + + } + + @And("User context clicks Phase {string}") + public void userContextClicksPhase(String arg0) { + + } + + @And("user selects {string}") + public void userSelects(String arg0) { + + } + + @And("User clicks {string} button") + public void userClickOnSaveButton(String arg0) { + + } + + @And("selects report type {string}, output as {string}, versions {string} and title {string}") + public void selectsReportTypeOutputAsVersionsAndTitle(String arg0, String arg1, String arg2, String arg3) { + + } + + @And("user clicks {string} checkbox in Customize and Export Reports") + public void userClicksCheckboxInCustomizeAndExportReports(String arg0) { + + } + + @When("User click on {string} button") + public void userClickOnDeleteButton(String arg0) { + } + + @And("User verify {string} status for export job on Export Progress window") + public void userVerifyStatusForExportJobOnExportProgressWindow(String arg0) { + + } + + @And("User click on {string} button on Download File window") + public void userClickOnButtonOnDownloadFileWindow(String arg0) { + + } + + @Then("user verify that file downloaded successfully with name {string}") + public void userVerifyThatFileDownloadedSuccessfullyWithName(String arg0) { + + } + + @When("User click on {string} Requirement in REQ grid to open detail view") + public void userClickOnRequirementInREQGridToOpenDetailView(String arg0) { + + } + + @And("User enter name {string}, description {string}, priority {string}, altId {string}") + public void userEnterNameDescriptionPriorityAltId(String arg0, String arg1, String arg2, String arg3) { + + } + + @And("User add attachments") + public void userAddAttachments() { + + } + + @Then("Requirement should be updated with all data successfully") + public void requirementShouldBeUpdatedWithAllDataSuccessfully() { + + } + + @And("User add custom field values") + public void userAddCustomFieldValues() { + + } + + @And("User click on Back to List button") + public void userClickOnBackToListButton() { + + } + + @And("User view Requirement name {string} in REQ grid") + public void userViewRequirementNameInREQGrid(String arg0) { + } + + @Given("User navigates to Test Repository App") + public void userNavigatesToTestRepositoryApp() { + + } + + @Then("User verify folder having text {string} in Folder name gets highlighted") + public void userVerifyFolderHavingTextInFolderNameGetsHighlighted(String arg0) { + + } + + @When("User click on {string} checkbox in TCR grid") + public void userClickOnCheckboxInTCRGrid(String arg0) { + + } + + @And("User do Ctrl+DnD to {string} folder") + public void userDoCtrlDnDToFolder(String arg0) { + + + } + + @Then("User verify testcases copied successfully to {string} folder") + public void userVerifyTestcasesCopiedSuccessfullyToFolder(String arg0) { + } + + @And("User enter map details map name {string}, row number and discriminator {string} on create new excel map window") + public void userEnterMapDetailsMapNameRowNumberRowNumAndDiscriminatorOnCreateNewExcelMapWindow(String arg0, String arg1) { + + } + + @And("User enter zephyr field details testcase name {string} and altId {string}") + public void userEnterZephyrFieldDetailsTestcaseNameAndAltId(String arg0, String arg1) { + + } + + @Then("Map should be created successfully with name {string}") + public void mapShouldBeCreatedSuccessfullyWithName(String arg0) { + + } + + @And("User navigate to Search Page") + public void userNavigateToSearchPage() { + + } + + @And("User click on {string} checkbox on Customize and Export Reports window") + public void userClickOnCheckboxOnCustomizeAndExportReportsWindow(String arg0) { + + } + + @And("user select report type {string}, output as {string}, versions {string} and title {string}") + public void userSelectReportTypeOutputAsVersionsAndTitle(String arg0, String arg1, String arg2, String arg3) { + + } + + @And("User click on {string} button for map {string}") + public void userClickOnButtonForMap(String arg0, String arg1) { + + } + + @And("User enter Job details job name {string} and select file {string} to import on create new import job window") + public void userEnterJobDetailsJobNameAndSelectFileToImportOnCreateNewImportJobWindow(String arg0, String arg1) { + + } + + @Then("User verify {string} status for job {string}") + public void userVerifyStatusForJob(String arg0, String arg1) { + + } + + @And("User enter text {} in {string} textbox") + public void userEnterTextInTextbox(String arg0, String arg1) { + } + + @And("User verify testcases satisfying {} condition are visible in TCR search grid") + public void userVerifyTestcasesSatisfyingConditionAreVisibleInTCRSearchGrid(String arg0) { + } + + @And("User close {string} window") + public void userCloseWindow(String arg0) { + } + + @And("User navigates to {string}{string} folder") + public void userNavigatesToFolder(String arg0, String arg1) { + + } + + @And("User verify imported test cases in {string} folder") + public void userVerifyImportedTestCasesInFolder(String arg0) { + } + + @When("I long {int} hour") + public void iLongHour(int arg0) { + + } + + @Then("my chest should fill") + public void myChestShouldFill() { + } } diff --git a/src/test/resources/io/cucumber/zephyr/admin.feature b/src/test/resources/io/cucumber/zephyr/admin.feature new file mode 100644 index 0000000..5259a1e --- /dev/null +++ b/src/test/resources/io/cucumber/zephyr/admin.feature @@ -0,0 +1,42 @@ +@JIRA_XYZ-1 @JIRA_XYZ-2 @smoke-test +Feature: Admin + + @Admin_1 + Scenario: Reset the Estimated time + Given Navigate to "Administration -> Customization" + And Click on Estimated Time Button + When User Click on reset Estimated Time Button + And User click on save button on "Default Estimated Time Editor" window + And User click on "YES" button on "confirmation pop-up" window + And Click on Estimated Time Button + Then User view the default estimated time as "blank" + + @Admin_2 + Scenario Outline: Create Normal, Isolated and Restricted project with mandatory fields only + Given Navigate to "Administration -> Project Setup" + When User click on Add Project button + And User enters project name "" and startdate "" + And User selects project type as "" + And User click on Add button + Then Project should be created successfully with project name "" and project type "" + Examples: + | projectname | startdate | projecttype | + | NormalProject | 05/18/2023 | Normal | + | IsolatedProject | 05/18/2023 | Isolated | + | RestrictedProject | 05/18/2023 | Restricted | + + @Admin_3 + Scenario Outline: User should be able to trigger full reindex for each entity individually + Given Navigate to "Administration -> Customization" + And User clicks on Indexing Button + And User click on Full Reindexing button on Indexing window + When User select "" entity from Select Entities to reindex dropdown + And User click on Reindex button + Then User verify job in indexing grid for "" entity with "Enqueue" status + Examples: + | entity | + | Testcase | + | Testcase Tree | + | Requirement | + | Execution | + | Requirement Tree | \ No newline at end of file diff --git a/src/test/resources/io/cucumber/zephyr/belly.feature b/src/test/resources/io/cucumber/zephyr/belly.feature index 4df54e8..69f1588 100644 --- a/src/test/resources/io/cucumber/zephyr/belly.feature +++ b/src/test/resources/io/cucumber/zephyr/belly.feature @@ -12,3 +12,12 @@ Feature: Belly Given I have 42 cukes in my belly When I wait 1 hour Then my belly should growl + + @JIRA_XYZ-5 + Scenario: some cakes 2 + Given I have 23 cakes in my belly + When I long 5 hour + Then my chest should fill + + @JIRA_XYZ-6 + Scenario: some cakes 3 \ No newline at end of file diff --git a/src/test/resources/io/cucumber/zephyr/req.feature b/src/test/resources/io/cucumber/zephyr/req.feature new file mode 100644 index 0000000..9c4e598 --- /dev/null +++ b/src/test/resources/io/cucumber/zephyr/req.feature @@ -0,0 +1,54 @@ +@JIRA_XYZ-1 @JIRA_XYZ-2 @smoke-test +Feature: REQ + + @REQ_1 + Scenario Outline: Delete created Phase with system and subsystem with tests at each level. + Given User navigates to Requirement App + And User navigates to "" + When User context click on folder "" + And User click on "Delete" Button + Then Folder "" with Requirement should be deleted successfully + Examples: + | level | folder | + | Project Test : GlobalSystem : GlobalSubSystem | GlobalSubSystem | + | Project Test : GlobalSystem | GlobalSystem | + | Project Test : GlobalPhase | GlobalPhase | + + @REQ_2 + Scenario Outline: Export Requirement from grid in (All report and output type) + Given User navigates to Requirement App + And User context clicks Phase "Phase1" + And user selects "Export Requirement" + And User clicks "Requirement only" button + And user clicks "select all" checkbox in Customize and Export Reports + And selects report type "", output as "", versions "" and title "" + When User click on "Save" button + And User verify "Success" status for export job on Export Progress window + And User click on "Download" button on Download File window + Then user verify that file downloaded successfully with name "" + Examples: + | report | output | version | report name | + | Summary | HTML | Current | TestSummaryHTML | + | Summary | PDF | Current | TestSummaryPDF | + | Summary | Word | Current | TestSummaryWord | + | Detailed | HTML | Current | TestDetailedHTML | + | Detailed | PDF | Current | TestDetailedPDF | + | Detailed | Word | Current | TestDetailedWord | + | Data(Excel Only) | PDF | Current | TestExcelPDF | + + @REQ_3 + Scenario Outline: Update Requirement with all fields in detail view at release level + Given User navigates to Requirement App + And User navigates to "" + When User click on "Untitled" Requirement in REQ grid to open detail view + And User enter name "", description "", priority "", altId "" + And User add attachments + And User add custom field values + Then Requirement should be updated with all data successfully + And User click on Back to List button + And User view Requirement name "" in REQ grid + Examples: + | level | name | desc | priority | altid | + | Release 1.0 : REQPhase2 | REQPhase Test2 | REQPhase2 | P3 | tes-1 | + | Release 1.0 : REQPhase2 : REQSystem2 | REQSystem Test2 | REQSystem2 | P3 | tes-2 | + | Release 1.0 : REQPhase2 : REQSystem2 : REQSubSystem2 | REQSubSystem Test1 | REQSubSystem2 | P3 | tes-3 | diff --git a/src/test/resources/io/cucumber/zephyr/tcr.feature b/src/test/resources/io/cucumber/zephyr/tcr.feature new file mode 100644 index 0000000..29a5232 --- /dev/null +++ b/src/test/resources/io/cucumber/zephyr/tcr.feature @@ -0,0 +1,76 @@ +@JIRA_XYZ-1 @JIRA_XYZ-2 @smoke-test +Feature: TCR + + @TCR_1 + Scenario Outline: Export multi-selected ZQL search results in Testcases (All Fields/Detailed/PDF) + Given User navigates to Test Repository App + And User navigate to Search Page + And User enter text "" in "Advance Search" textbox + And User click on "GO" button + And User verify testcases satisfying "" condition are visible in TCR search grid + When User click on "Export" Button + And User click on "Select All" checkbox on Customize and Export Reports window + And user select report type "", output as "", versions "" and title "" + And User click on "Save" button + Then User verify "Success" status for export job on Export Progress window + And User click on "Download" button on Download File window + And user verify that file downloaded successfully with name "" + Examples: + | condition | report | output | version | report name | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Summary | HTML | Current | TestSearchSummaryHTML | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Summary | PDF | Current | TestSearchSummaryPDF | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Summary | Word | Current | TestSearchSummaryWord | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Detailed | HTML | Current | TestSearchDetailedHTML | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Detailed | PDF | Current | TestSearchDetailedPDF | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Detailed | Word | Current | TestSearchDetailedWord | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | Data(Excel Only) | PDF | Current | TestSearchExcelPDF | + + + @tcr_2 + Scenario: Ctrl+DnD (copy) 2-3 testcase from project release to local release + Given User navigates to Test Repository App + And User navigates to "Release 1.0 : TCRPhase : TCRSystem : TCRSubSystem" + And User navigates to "Project Test Repository : GlobalPhase : GlobalSystem : GlobalSubSystem" + When User click on "Select All" checkbox in TCR grid + And User do Ctrl+DnD to "Release 1.0 : TCRPhase : TCRSystem : TCRSubSystem" folder + Then User verify testcases copied successfully to "Release 1.0 : TCRPhase : TCRSystem : TCRSubSystem" folder + + + @TCR_3 + Scenario Outline: Search testcase by advance search(single/multiple condition) with all supported fields + Given User navigates to Test Repository App + And User navigate to Search Page + When User enter text "" in "Advance Search" textbox + And User click on "GO" button + Then User verify testcases satisfying "" condition are visible in TCR search grid + Examples: + | condition | + | estimatedTime is not "empty" | + | estimatedTime = "11:11:11.000" | + | testcaseId in (1, 2, 3, 10) and creator != "test.manager" | + | release = "Project Test Repository" and priority is "empty" | + | altId ~ "test" or comment ~ "Phase" | + | tag = "system" and altId ~ "test" and priority in ("P1", "P2") | + | automated = true and version = 1 | + | folder = "TCRPhase" and name = "TCRPhase Test" | + | versionId != 1 | + | CFCheckBox = "true" or CFText ~ "TCRPhase" | + | contents ~ "TCRPhase Step" | + + @TCR_4 + Scenario Outline: Import testcases(by id change/empty row/testcase name change) and view the folder name + Given User navigates to Test Repository App + When User click on "Import" button + And User click on "Create Job" button for map "" + And User enter Job details job name "" and select file "" to import on create new import job window + And User click on "Start Import" button + Then User verify "Success" status for job "" + And User close "Import Job Progress" window + And User close "Import Test Cases" window + And User navigates to "Imported :""" folder + And User verify imported test cases in "" folder + Examples: + | map name | job name | file | + | Map_EmptyRow | Job_EmptyRow | test.xlsx | + | Map_IdChange | Job_IdChange | test.xlsx | + | Map_NameChange | Job_NameChange | test.xlsx | \ No newline at end of file