Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HermansJarno opened this issue Oct 14, 2024 · 9 comments
Open

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

HermansJarno opened this issue Oct 14, 2024 · 9 comments

Comments

@HermansJarno
Copy link

This is my junit file:

<?xml version="1.0" encoding="UTF-8"?> <testsuites tests="1" failures="0" errors="0" skipped="0"> <testsuite name="Zoekopdracht op google" timestamp="2024-10-14T08:39:03" time="6.184" tests="1" failures="0" errors="0" skipped="0"> <properties> <property name="specId" value="0"/> <property name="featureName" value="Zoekopdracht op google"/> <property name="capabilities" value="chrome.129_0_6668_59.windows"/> <property name="featureFile" value="file:///C:/APPS/test-project/tests/features/google-voorbeeld.feature"/> </properties> <testcase classname="CucumberJUnitReport-chrome.129_0_6668_59.windows.Zoekopdracht op google" name="abc" time="5.489"> <system-out><![CDATA[ ✅ Gegeven dat de google zoekpagina geladen is✅ Als er wordt gezocht naar "ABC"✅ Dan wordt "abc.nl" als eerste resultaat getoond ]]></system-out> </testcase> </testsuite> </testsuites>

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: <testsuite tests="1" failures="0" name="Zoekopdracht op google" time="6.184" errors="0" timestamp="2024-10-14T08:39:03" skipped="0" >...</testsuite> 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
Copy link
Author

HermansJarno commented Oct 15, 2024

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
Copy link

Glenn-APG commented Oct 18, 2024

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"?> <testsuite failures="1" skipped="0" name="cucumber-js" time="13.042797896" tests="1"> <testcase classname="Zoekopdracht op google" name="abc" time="13.042797896"> <failure type="Error" message="function timed out, ensure the promise resolves within 10000 milliseconds"><![CDATA[Error: function timed out, ensure the promise resolves within 10000 milliseconds at Timeout.<anonymous> (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)]]></failure> <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...........................failed]]></system-out> </testcase> </testsuite>

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)

@nissimshitrit
Copy link
Collaborator

Hello,
It seems that the format of Junit report is not to what has been implemented in bdd2octane tool for cucumber-js framework
What is the cucumber-js version you are using?

@Glenn-APG
Copy link

Hello @nissimshitrit, we are using @wdio/cucumber-framework library with version 9.2.2 which is the latest, this library uses @cucumber/cucumber version 10.3.1.

@nissimshitrit
Copy link
Collaborator

Those are the supported verified versions for cucumber-js: 4.2.1, 5.1.0, 6.0.5, 7.3.0
probably new version is not working yes since we didn't added support for it, you can add request for this from our support

@Glenn-APG
Copy link

@nissimshitrit, We'll create a ticket for this, thanks!

@NikolaZag
Copy link

I am facing similar issues with bdd2octane, the problem is that I am not using wdio and can’t setup the /*.ts file which matches the feature file and the feature files are skipped.

@nissimshitrit
Copy link
Collaborator

Hi @NikolaZag ,
Can you share more details on your issue ?
Which framework are you using ?
Which cucumber version?
Do you have example of test run output and the related feature files?
Are you getting the "Skipped" from bdd2octane?

@NikolaZag
Copy link

@nissimshitrit
I think I might have found the issue. There is a feature file missing for some steps. I've masked the names of the feature files.
All xml files matching pattern "**/test-results/resultsOctane.xml": test-results/resultsOctane.xml All feature files matching pattern "**/features/*.feature": features/xxxxx.feature features/xxxxxxxx.feature features/xxxxxx.feature features/xxxxxxxxxx.feature features/xxxxxxxxxx.feature features/xxxxxxxxxx.feature features/xxxxxxxxxx.feature features/test.feature features/xxxxxxxxxx.feature Cannot locate a feature file for: features/test.feature.spec.js skipping ... 0 test case(s) processed 1 test case(s) skipped

The Setup is a little bit odd, but it is working.
Running Playwight tests with Cucumber in a Jenkins nodejs container agent. After the tests are executed all the feature files, xml report and bdd2octane.jar are stashed. Then Another container is created with java, all the files are unstashed and the bdd2octane.jar is executed with parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants