MicroFocus / bdd2octane

Apache License 2.0
0 stars 9 forks source link

Can you give a valid cucumber-js example? #34

Open HermansJarno opened 1 week ago

HermansJarno commented 1 week ago

This is my junit file:

`<?xml version="1.0" encoding="UTF-8"?>

`

This is my feature file:

`#Auto generated Octane revision tag @BSPID40002REV0.2.0 Feature: Zoekopdracht op google """ Als ABC Wil ik controleren dat ABC het eerste resultaat is op Google Zodat ABC snel te vinden is """

@TSCID247004 Scenario: abc Given dat de google zoekpagina geladen is When er wordt gezocht naar "ABC" Then wordt "ABC.nl" als eerste resultaat getoond`

This my output in commandline: `java -jar "C:\temp_TA\bdd2octane-1.1.9.jar" --framework="cucumber-js" --reportFiles="/junit-report.xml" --featureFiles="/tests/features/.feature" --resultFile="bdd2octane\octane-report.xml" All xml files matching pattern "/junit-report.xml": junit-report.xml All feature files matching pattern "/tests/features/.feature": tests\features\google-voorbeeld.feature Feature name is empty in element:

... try searching by scenario name Cannot locate a feature file by scenario name for: Zoekopdracht op google, skipping... 0 test case(s) processed 1 test case(s) skipped` The cucumber version and junit version is imo irrelevant for this issue. We've tried to adjust our junit to the unit test examples in this repository but no success. Please provide a working example.
HermansJarno commented 1 week ago

We've come to a working example:

the output:

java -jar "C:\temp_TA\bdd2octane-1.1.9.jar" --framework="cucumber-jvm" --reportFiles="**/cucumber-junit.xml" --featureFiles="**/tests/features/*.feature" --resultFile="bdd2octane\octane-report.xml"
All xml files matching pattern "**/cucumber-junit.xml":
        cucumber-junit.xml
All feature files matching pattern "**/tests/features/*.feature":
        tests\features\google-voorbeeld.feature
1 test case(s) processed
0 test case(s) skipped

The xml:

cucumber-junit.xml:

<?xml version="1.0"?>
<testsuite failures="0" skipped="0" name="cucumber-js" time="10.916969993" tests="1">
  <testcase classname="Zoekopdracht op google" name="abc.nl is het eerste resultaat op Google" time="10.916969993">
    <system-out><![CDATA[Gegeven dat de google zoekpagina geladen is...............................passed
Als er wordt gezocht naar "ABC"...........................................passed
Dan wordt "abc.nl" als eerste resultaat getoond...........................passed]]></system-out>
  </testcase>
</testsuite>

the wdio config:

cucumberOpts: {
        require: ['./src/steps/**/*.ts'],
        format: [
            'junit:./cucumber-junit.xml'
            ]
    },

Is it normal that we have to use jvm as framework for a javascript testing framework such as wdio?

Glenn-APG commented 6 days ago

In Jarno's first comment, we used a junit report generated by the npm library @wdio/junit-reporter along with its associated error when compiling the junit report with the bdd2octane tool.

In Jarno's second comment with the workaround of using 'cucumber-jvm' instead of 'cucumber-js', we used a junit report which was generated by the npm library @cucumber/cucumber. The bdd2octane tool was able to convert this junit report to an octane report BUT it works only for junit reports that contain successful tests only. If the junit report contains failed tests, we get a StringIndexOutOfBoundsException and the octane report won't be generated:

java -jar "C:\xxxxxx\bdd2octane-1.1.9.jar" --framework="cucumber-jvm" --reportFiles="**/cucumber-junit.xml" --featureFiles="**/tests/features/*.feature" --resultFile="bdd2octane\octane-report.xml" All xml files matching pattern "**/cucumber-junit.xml": cucumber-junit.xml All feature files matching pattern "**/tests/features/*.feature": tests\features\google-voorbeeld.feature Exception in thread "main" java.lang.StringIndexOutOfBoundsException: begin 237, end -1, length 286 at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602) at java.base/java.lang.String.substring(String.java:2705) at com.microfocus.bdd.LinesIterator.next(LinesIterator.java:53) at com.microfocus.bdd.LinesIterator.next(LinesIterator.java:36) at com.microfocus.bdd.CucumberJvmHandler.findFirstStarLine(CucumberJvmHandler.java:147) at com.microfocus.bdd.CucumberJvmHandler.setElement(CucumberJvmHandler.java:94) at com.microfocus.bdd.Bdd2Octane.run(Bdd2Octane.java:85) at com.microfocus.bdd.App.main(App.java:62)

The cucumber-junit.xml file with a failed test step:

`<?xml version="1.0"?>

(C:\xxxxx\node_modules\@cucumber\cucumber\src\time.ts:52:14) at listOnTimeout (node:internal/timers:569:17) at processTimers (node:internal/timers:512:7)]]>

`

The approach using cucumber-jvm is a workaround that somewhat works (for junit reports containing passed tests only), but we expected to be able to set 'cucumber-js' as framework when using wdio instead of 'cucumber-jvm' which is not related towards each other.

When we use a passed cucumber-junit.xml with 'cucumber-js', then we get following java.util.NoSuchElementException error:

java -jar "C:\xxxxxx\bdd2octane-1.1.9.jar" --framework="cucumber-js" --reportFiles="**/cucumber-junit.xml" --featureFiles="**/tests/features/*.feature" --resultFile="bdd2octane\octane-report.xml" All xml files matching pattern "**/cucumber-junit.xml": cucumber-junit.xml All feature files matching pattern "**/tests/features/*.feature": tests\features\google-voorbeeld.feature Exception in thread "main" java.util.NoSuchElementException: No value present at java.base/java.util.Optional.get(Optional.java:143) at com.microfocus.bdd.CucumberJsHandler.findFeatureFile(CucumberJsHandler.java:129) at com.microfocus.bdd.CucumberJsHandler.getFeatureFile(CucumberJsHandler.java:88) at com.microfocus.bdd.Bdd2Octane.run(Bdd2Octane.java:88) at com.microfocus.bdd.App.main(App.java:62)