Skip to content

Commit

Permalink
Merge pull request #12 from MicroFocus/1.1.3
Browse files Browse the repository at this point in the history
defect #2110046: fix case when feature file hae space. handle when re…
  • Loading branch information
nissimshitrit authored Jun 29, 2023
2 parents 26237c7 + ccc70d0 commit 50e01af
Show file tree
Hide file tree
Showing 12 changed files with 437 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.microfocus.adm.almoctane.bdd</groupId>
<artifactId>bdd2octane</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.1.3-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>bdd2octane</name>
Expand Down
32 changes: 20 additions & 12 deletions src/main/java/com/microfocus/bdd/Bdd2Octane.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.*;

import static java.nio.charset.StandardCharsets.UTF_8;


public class Bdd2Octane {

Expand Down Expand Up @@ -157,20 +160,25 @@ private void mergeScenario(BddFrameworkHandler bddFrameworkHandler, OctaneScenar

private Optional<String> canonicalizeFilePath(String featureFile) {
return featureFiles.stream().filter(f -> {
if (featureFile.startsWith("file:///")) {
try {
URI uri = new URI(featureFile);
return Paths.get(f).toUri().equals(uri);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
try {
if (featureFile.startsWith("file:///")) {
try {
URI uri = new URI(featureFile);
return Paths.get(f).toUri().equals(uri);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
} else if (featureFile.startsWith("file:")) {
return Paths.get(URLDecoder.decode(f,StandardCharsets.UTF_8.toString())).endsWith(URLDecoder.decode(featureFile.substring(5), StandardCharsets.UTF_8.toString()));
} else if (featureFile.startsWith("classpath:")) {
return Paths.get(URLDecoder.decode(f,StandardCharsets.UTF_8.toString())).endsWith(URLDecoder.decode(featureFile.substring(10), StandardCharsets.UTF_8.toString()));
} else {
return Paths.get(URLDecoder.decode(f,StandardCharsets.UTF_8.toString())).endsWith(URLDecoder.decode(featureFile, StandardCharsets.UTF_8.toString()));
}
} else if (featureFile.startsWith("file:")) {
return Paths.get(f).endsWith(featureFile.substring(5));
} else if (featureFile.startsWith("classpath:")) {
return Paths.get(f).endsWith(featureFile.substring(10));
} else {
return Paths.get(f).endsWith(featureFile);
}catch (IllegalArgumentException | UnsupportedEncodingException e){
System.err.println("Failed to decode feature file from report. feature file:" +featureFile + ", error: " + e.getMessage());
}
return false;
}).findFirst();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/microfocus/bdd/CucumberJvmHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setElement(Element element) {

errorMessage = child.getText();
String lastLine = findLastNonEmptyLine(errorMessage);
if (lastLine.startsWith("at ✽.")) {
if (lastLine.startsWith("at ✽.") || lastLine.startsWith("at ?.")) {
extractFeatureFilePath(lastLine);
} else {
Optional<String> optionalString = findFirstStarLine(errorMessage);
Expand Down Expand Up @@ -111,7 +111,7 @@ private String findLastNonEmptyLine(String message) {

private Optional<String> findFirstStarLine(String message) {
for (String line : getLines(message)) {
if (line.startsWith("at ✽.")) {
if (line.startsWith("at ✽.") || line.startsWith("at ?.")) {
return Optional.of(line);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public static List<Object[]> data() {
//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"},
//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"}
{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"},

{Framework.CUCUMBER_JVM, "src/test/resources/cucumber-jvm/separate-test6/junit.xml", "src/test/resources/features/Calculator.feature", "separateResults/cucumber-jvm-final6.xml", "**/separateResults/standard-cucumber-jvm-final6.xml"},

{Framework.CUCUMBER_JVM, "src/test/resources/cucumber-jvm/space_feature_file/junit.xml", "src/test/resources/features/Check*.feature", "separateResults/cucumber-jvm-final7.xml", "**/separateResults/standard-cucumber-jvm-final7.xml"}

});

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/microfocus/bdd/ut/FilesLocatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public void matchPatternFailTest() {
public void matchPatternPassTest() {
final String pattern = "src/**/*junit*.xml";
List<String> reports = FilesLocator.getReportFiles(pattern);
Assert.assertEquals(16, reports.size());
Assert.assertEquals(18, reports.size());
}
}
30 changes: 30 additions & 0 deletions src/test/resources/cucumber-jvm/separate-test6/junit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="Cucumber" time="0.413" tests="3" skipped="0" failures="1" errors="0">
<testcase classname="Basic Calculator" name="Simple add operation" time="0.035">
<system-out><![CDATA[
When I "add" 1 and 1........................................................passed
Then the result is 2........................................................passed
]]></system-out>
</testcase>
<testcase classname="Basic Calculator" name="Combine basic operations" time="0.15">
<failure type="io.kotest.assertions.AssertionFailedError" message="expected:&lt;43.0&gt; but was:&lt;42.0&gt;">
<![CDATA[io.kotest.assertions.AssertionFailedError: expected:<43.0> but was:<42.0>
at glue.CalculationSteps.checkResult(CalculationSteps.kt:74)
at ?.the result is 43(file:Calculator.feature:10)
]]>
</failure>
<system-out><![CDATA[
When I "add" 10 and 11......................................................passed
And I "multiply with" 2.....................................................passed
Then the result is 43.......................................................failed
]]></system-out>
</testcase>
<testcase classname="Basic Calculator" name="Combine more operations" time="0">
<system-out><![CDATA[
When I "add" 10 and 12......................................................passed
And I "subtract" 1..........................................................passed
And I "multiply with" 2.....................................................passed
Then the result is 42.......................................................passed
]]></system-out>
</testcase>
</testsuite>
105 changes: 105 additions & 0 deletions src/test/resources/cucumber-jvm/space_feature_file/junit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="10" failures="2" name="MyTest" time="0.016" errors="0" skipped="2">
<properties>
<property name="idea.version" value="2022.3.1"/>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="11.0.11+9"/>
<property name="sun.boot.library.path" value="C:\Program Files\AdoptOpenJDK\bin"/>
<property name="maven.multiModuleProjectDirectory" value="C:\Program Files\Jenkins\.jenkins\workspace\BddInjectionFileSystem"/>
<property name="java.vm.vendor" value="AdoptOpenJDK"/>
<property name="java.vendor.url" value="https://adoptopenjdk.net/"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="path.separator" value=";"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="sun.os.patch.level" value=""/>
<property name="user.script" value=""/>
<property name="user.country" value="US"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="C:\Program Files\Jenkins\.jenkins\workspace\BddInjectionFileSystem"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="java.runtime.version" value="11.0.11+9"/>
<property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
<property name="os.arch" value="amd64"/>
<property name="java.io.tmpdir" value="C:\Users\NShitrit\AppData\Local\Temp\"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows 10"/>
<property name="maven.ext.class.path" value="C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\plugins\maven\lib\maven-event-listener.jar"/>
<property name="classworlds.conf" value="C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\plugins\maven\lib\maven3\bin\m2.conf"/>
<property name="sun.jnu.encoding" value="Cp1252"/>
<property name="java.library.path" value="C:\Program Files\AdoptOpenJDK\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\AdoptOpenJDK\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Yarn\bin\;C:\tools\elasticsearch-7.17.6\bin;C:\Program Files\PostgreSQL\11\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\dotnet\;C:\Program Files (x86)\Micro Focus\UFT One\bin;C:\Program Files\Novell\iPrint;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X86\;C:\Program Files\nodejs\;C:\Program Files\TortoiseGit\bin;C:\Users\NShitrit\AppData\Local\Programs\Rancher Desktop\resources\resources\win32\bin;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Common Files\Pulse Secure\TNC Client Plugin\;C:\Program Files\Rancher Desktop\resources\resources\win32\bin\;C:\Program Files\Rancher Desktop\resources\resources\linux\bin\;C:\Users\NShitrit\AppData\Local\Microsoft\WindowsApps;C:\Users\NShitrit\AppData\Local\Yarn\bin;C:\Program Files\Azure Data Studio\bin;C:\Users\NShitrit\AppData\Roaming\npm;C:\Users\NShitrit\MicrosoftVSCode\bin;."/>
<property name="jansi.passthrough" value="true"/>
<property name="maven.conf" value="C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\plugins\maven\lib\maven3/conf"/>
<property name="jdk.debug" value="release"/>
<property name="java.class.version" value="55.0"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="os.version" value="10.0"/>
<property name="user.home" value="C:\Users\NShitrit"/>
<property name="user.timezone" value="Asia/Jerusalem"/>
<property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.specification.version" value="11"/>
<property name="user.name" value="NShitrit"/>
<property name="java.class.path" value="C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\plugins\maven\lib\maven3\boot\plexus-classworlds.license"/>
<property name="java.vm.specification.version" value="11"/>
<property name="sun.arch.data.model" value="64"/>
<property name="sun.java.command" value="org.codehaus.classworlds.Launcher -Didea.version=2022.3.1 clean test"/>
<property name="java.home" value="C:\Program Files\AdoptOpenJDK"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="java.version" value="11.0.11"/>
<property name="java.vendor" value="AdoptOpenJDK"/>
<property name="maven.home" value="C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\plugins\maven\lib\maven3"/>
<property name="file.separator" value="\"/>
<property name="java.version.date" value="2021-04-20"/>
<property name="java.vendor.url.bug" value="https://github.com/AdoptOpenJDK/openjdk-support/issues"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="sun.cpu.endian" value="little"/>
<property name="java.vendor.version" value="AdoptOpenJDK-11.0.11+9"/>
<property name="sun.desktop" value="windows"/>
<property name="sun.cpu.isalist" value="amd64"/>
</properties>
<testcase classname="Approve" name="ApproveScenario1" time="0.008"/>
<testcase classname="Approve" name="Approve" time="0.002">
<skipped/>
</testcase>
<testcase classname="Approve" name="Online" time="0.002"/>
<testcase classname="Approve" name="Online" time="0"/>
<testcase classname="Approve" name="Online" time="0"/>
<testcase classname="Approve" name="Online" time="0.003">
<failure message="expected:&lt;1&gt; but was:&lt;2&gt;" type="java.lang.AssertionError">java.lang.AssertionError: expected:&lt;1&gt; but was:&lt;2&gt;
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at MyStepdefs.some(MyStepdefs.java:29)
at ✽.3(file:src/test/resources/features/Check%20Account%20Approve.feature:22)
</failure>
<system-out>some: 6
some: 3
</system-out>
</testcase>
<testcase classname="apscen21" name="app11" time="0"/>
<testcase classname="apscen21" name="sda11" time="0.001">
<failure message="expected:&lt;1&gt; but was:&lt;2&gt;" type="java.lang.AssertionError">java.lang.AssertionError: expected:&lt;1&gt; but was:&lt;2&gt;
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:631)
at MyStepdefs.some(MyStepdefs.java:29)
at ✽.1(file:src/test/resources/features/Check%20Account%20app.feature:15)
</failure>
<system-out>some: 1
</system-out>
</testcase>
<testcase classname="apscen21" name="sda11" time="0"/>
<testcase classname="apscen21" name="sda11" time="0">
<skipped/>
</testcase>
</testsuite>
16 changes: 16 additions & 0 deletions src/test/resources/features/Calculator.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Feature: Basic Calculator

Scenario: Simple add operation
When I "add" 1 and 1
Then the result is 2

Scenario: Combine basic operations
When I "add" 10 and 11
And I "multiply with" 2
Then the result is 43

Scenario: Combine more operations
When I "add" 10 and 12
And I "subtract" 1
And I "multiply with" 2
Then the result is 42
29 changes: 29 additions & 0 deletions src/test/resources/features/Check Account Approve.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#Auto generated Octane revision tag
@BSPID1009REV0.2.0
Feature: Approve


@TSCID1023
Scenario: ApproveScenario1
Given numberOdd
When one
Then one

@TSCID1024
Scenario: Approve
Given numberEven12
When three
Then three

@TSCID1025
Scenario Outline: Online
Given all
When <param2>
Then <param1>

Examples:
| param1 | param2 |
| 2 | 4 |
| 4 | 8 |
| 2 | 2 |
| 3 | 6 |
22 changes: 22 additions & 0 deletions src/test/resources/features/Check Account app.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#Auto generated Octane revision tag
@BSPID1010REV0.2.0
Feature: apscen21

@TSCID1026
Scenario: app11
Given dsf
When df1
Then df2


@TSCID1027
Scenario Outline: sda11
Given <param1>
When <param2>
Then sdf

Examples:
| param1 | param2 |
| a | 1 |
| b | 2 |
| c | 3 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" ?>
<!--Generated by bdd2octane 1.1.2-SNAPSHOT-->
<features version="1">
<feature name="Basic Calculator" path="src\test\resources\features\Calculator.feature" started="1687439158592" tag="">
<file>
<![CDATA[Feature: Basic Calculator
Scenario: Simple add operation
When I "add" 1 and 1
Then the result is 2
Scenario: Combine basic operations
When I "add" 10 and 11
And I "multiply with" 2
Then the result is 43
Scenario: Combine more operations
When I "add" 10 and 12
And I "subtract" 1
And I "multiply with" 2
Then the result is 42
]]>
</file>
<scenarios>
<scenario name="Simple add operation">
<steps>
<step name="When I &quot;add&quot; 1 and 1" duration="0" status="passed"></step>
<step name="Then the result is 2" duration="0" status="passed"></step>
</steps>
</scenario>
<scenario name="Combine basic operations">
<steps>
<step name="When I &quot;add&quot; 10 and 11" duration="0" status="passed"></step>
<step name="And I &quot;multiply with&quot; 2" duration="0" status="passed"></step>
<step name="Then the result is 43" duration="0" status="failed">
<error_message><![CDATA[io.kotest.assertions.AssertionFailedError: expected:<43.0> but was:<42.0>
at glue.CalculationSteps.checkResult(CalculationSteps.kt:74)
at ?.the result is 43(file:Calculator.feature:10)
]]></error_message>
</step>
</steps>
</scenario>
<scenario name="Combine more operations">
<steps>
<step name="When I &quot;add&quot; 10 and 12" duration="0" status="passed"></step>
<step name="And I &quot;subtract&quot; 1" duration="0" status="passed"></step>
<step name="And I &quot;multiply with&quot; 2" duration="0" status="passed"></step>
<step name="Then the result is 42" duration="0" status="passed"></step>
</steps>
</scenario>
</scenarios>
</feature>
</features>
Loading

0 comments on commit 50e01af

Please sign in to comment.