diff --git a/src/main/java/com/microfocus/bdd/CucumberJvmHandler.java b/src/main/java/com/microfocus/bdd/CucumberJvmHandler.java index 974ccb0..fb4bdd5 100644 --- a/src/main/java/com/microfocus/bdd/CucumberJvmHandler.java +++ b/src/main/java/com/microfocus/bdd/CucumberJvmHandler.java @@ -63,36 +63,36 @@ public void setElement(Element element) { errorMessage = child.getText(); String lastLine = findLastNonEmptyLine(errorMessage); if (lastLine.startsWith("at ✽.")) { - int startOfFileLocation = lastLine.lastIndexOf("("); - failedStep = lastLine.substring(5, startOfFileLocation); - featureFile = lastLine.substring(startOfFileLocation + 1, lastLine.lastIndexOf(')')); - int lineNumIndex = featureFile.lastIndexOf(':'); - failedLineNum = featureFile.substring(lineNumIndex + 1); - featureFile = featureFile.substring(0, lineNumIndex); + extractFeatureFilePath(lastLine); } else { - element.getChild("system-out").ifPresent(out -> { - errorMessage = out.getText(); - String failedLine = null; - int indexOfPeriod = 0; - for (String line: getLinesBottomUp(errorMessage)) { - if (line.startsWith("at ") && line.endsWith(")")) { - indexOfPeriod = line.indexOf('.'); - if (indexOfPeriod != -1) { - failedLine = line; - break; + Optional optionalString = findFirstStarLine(errorMessage); + if (optionalString.isPresent()) { + extractFeatureFilePath(optionalString.get()); + } else { + element.getChild("system-out").ifPresent(out -> { + errorMessage = out.getText(); + String failedLine = null; + int indexOfPeriod = 0; + for (String line : getLinesBottomUp(errorMessage)) { + if (line.startsWith("at ") && line.endsWith(")")) { + indexOfPeriod = line.indexOf('.'); + if (indexOfPeriod != -1) { + failedLine = line; + break; + } } } - } - if (failedLine == null) { - return; - } - int startOfFileLocation = failedLine.lastIndexOf("("); - failedStep = failedLine.substring(indexOfPeriod + 1, startOfFileLocation); - featureFile = failedLine.substring(startOfFileLocation + 1, failedLine.lastIndexOf(')')); - int lineNumIndex = featureFile.lastIndexOf(':'); - failedLineNum = featureFile.substring(lineNumIndex + 1); - featureFile = featureFile.substring(0, lineNumIndex); - }); + if (failedLine == null) { + return; + } + int startOfFileLocation = failedLine.lastIndexOf("("); + failedStep = failedLine.substring(indexOfPeriod + 1, startOfFileLocation); + featureFile = failedLine.substring(startOfFileLocation + 1, failedLine.lastIndexOf(')')); + int lineNumIndex = featureFile.lastIndexOf(':'); + failedLineNum = featureFile.substring(lineNumIndex + 1); + featureFile = featureFile.substring(0, lineNumIndex); + }); + } } } else if (childName.equals("skipped")) { isSkipped = true; @@ -109,10 +109,32 @@ private String findLastNonEmptyLine(String message) { return null; } + private Optional findFirstStarLine(String message) { + for (String line : getLines(message)) { + if (line.startsWith("at ✽.")) { + return Optional.of(line); + } + } + return Optional.empty(); + } + private Iterable getLinesBottomUp(String message) { return () -> new LinesBottomUpIterator(message); } + private Iterable getLines(String message) { + return () -> new LinesIterator(message); + } + + private void extractFeatureFilePath(String line) { + int startOfFileLocation = line.lastIndexOf("("); + failedStep = line.substring(5, startOfFileLocation); + featureFile = line.substring(startOfFileLocation + 1, line.lastIndexOf(')')); + int lineNumIndex = featureFile.lastIndexOf(':'); + failedLineNum = featureFile.substring(lineNumIndex + 1); + featureFile = featureFile.substring(0, lineNumIndex); + } + @Override public Optional getFeatureName() { String classname = element.getAttribute("classname"); diff --git a/src/main/java/com/microfocus/bdd/LinesIterator.java b/src/main/java/com/microfocus/bdd/LinesIterator.java new file mode 100644 index 0000000..615717d --- /dev/null +++ b/src/main/java/com/microfocus/bdd/LinesIterator.java @@ -0,0 +1,34 @@ +/* + * © Copyright [2021] Micro Focus or one of its affiliates. + * Licensed under Apache License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * http://www.apache.org/licenses/ + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ +package com.microfocus.bdd; + +import java.util.Iterator; + +class LinesIterator implements Iterator { + private String string; + + private int index = 0; + + public LinesIterator(String string) { + this.string = string; + } + + @Override + public boolean hasNext() { + return index < string.length(); + } + + @Override + public String next() { + int endIndexOfLine = string.indexOf('\n', index); + String nextLine = string.substring(index, endIndexOfLine).trim(); + index = endIndexOfLine + 1; + return nextLine; + } +} diff --git a/src/test/java/com/microfocus/bdd/it/Bdd2OctaneHandlerITCase.java b/src/test/java/com/microfocus/bdd/it/Bdd2OctaneHandlerITCase.java index 6b0d227..d79aab2 100644 --- a/src/test/java/com/microfocus/bdd/it/Bdd2OctaneHandlerITCase.java +++ b/src/test/java/com/microfocus/bdd/it/Bdd2OctaneHandlerITCase.java @@ -56,7 +56,9 @@ public static List data() { //2 discrete junit reports + 1 unrelated junit report {Framework.CUCUMBER_JVM, "src/test/resources/cucumber-jvm/separate-test3/*.xml", "src/test/resources/features/*.feature", "separateResults/cucumber-jvm-final3.xml", "**/separateResults/standard-cucumber-jvm-final3.xml"}, //1 junit report + 2 feature files - {Framework.CUCUMBER_JVM, "src/test/resources/cucumber-jvm/separate-test4/junit.xml", "src/test/resources/features/separate_test4*.feature", "separateResults/cucumber-jvm-final4.xml", "**/separateResults/standard-cucumber-jvm-final4.xml"} + {Framework.CUCUMBER_JVM, "src/test/resources/cucumber-jvm/separate-test4/junit.xml", "src/test/resources/features/separate_test4*.feature", "separateResults/cucumber-jvm-final4.xml", "**/separateResults/standard-cucumber-jvm-final4.xml"}, + //1 junit report + 3 feature files + {Framework.CUCUMBER_JVM, "src/test/resources/cucumber-jvm/separate-test5/junit.xml", "src/test/resources/features/MyAccount*.feature", "separateResults/cucumber-jvm-final5.xml", "**/separateResults/standard-cucumber-jvm-final5.xml"} }); diff --git a/src/test/resources/cucumber-jvm/separate-test5/junit.xml b/src/test/resources/cucumber-jvm/separate-test5/junit.xml new file mode 100644 index 0000000..ee2cfb6 --- /dev/null +++ b/src/test/resources/cucumber-jvm/separate-test5/junit.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/features/MyAccountFooterUIValidations.feature b/src/test/resources/features/MyAccountFooterUIValidations.feature new file mode 100644 index 0000000..1e5614b --- /dev/null +++ b/src/test/resources/features/MyAccountFooterUIValidations.feature @@ -0,0 +1,16 @@ +#Auto generated Octane revision tag +@BSPID174090REV0.18.0 +Feature: MyAccountFooterUIValidations + + @TSCID523715 @TemenosReactTeam + Scenario: Verify Footer - Our Fees Hyperlink + Given User logs into My Account with a policy + When User clicks on "Our Fees" link in My Account Footer + Then User should be navigated to the respective footer page + @TSCID523721 @TemenosReactTeam + Scenario: Verify Footer - Important Information About Us Hyperlink + Given User login into My Account with Multi Product Policies + |Bike | 1 | + |Van | 1 | + When User clicks on "Important Information About Us" link in My Account Footer + Then User should be navigated to the respective footer page \ No newline at end of file diff --git a/src/test/resources/features/MyAccountGoGreenOverlayUiValidations.feature b/src/test/resources/features/MyAccountGoGreenOverlayUiValidations.feature new file mode 100644 index 0000000..9e1874b --- /dev/null +++ b/src/test/resources/features/MyAccountGoGreenOverlayUiValidations.feature @@ -0,0 +1,9 @@ +#Auto generated Octane revision tag +@BSPID182030REV0.12.0 +Feature: MyAccount GoGreen Overlay Ui Validations + + @TSCID545389 @TemenosReactTeam + Scenario: Verify the Help us go green modal overlay for postal document delivery in My Account + Given User logs into My Account with Postal document delivery method policy + When User is on Dashboard screen for Go Green Modal + Then User should be presented with Help us go green modal overlay \ No newline at end of file diff --git a/src/test/resources/features/MyAccountHelpUIValidation.feature b/src/test/resources/features/MyAccountHelpUIValidation.feature new file mode 100644 index 0000000..50e38af --- /dev/null +++ b/src/test/resources/features/MyAccountHelpUIValidation.feature @@ -0,0 +1,9 @@ +#Auto generated Octane revision tag +@BSPID183048REV0.5.0 +Feature: MyAccountHelpUIValidation + + @TSCID564947 @TemenosReactTeam + Scenario: Verify Help page on My Account + Given User logs into My Account with a policy + When User clicks on Help button + Then User should be directed to the Hastings Direct Help page \ No newline at end of file diff --git a/src/test/resources/standardOctaneGherkinReport/separateResults/standard-cucumber-jvm-final5.xml b/src/test/resources/standardOctaneGherkinReport/separateResults/standard-cucumber-jvm-final5.xml new file mode 100644 index 0000000..d737169 --- /dev/null +++ b/src/test/resources/standardOctaneGherkinReport/separateResults/standard-cucumber-jvm-final5.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +