Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Fixes to cucumber step identification #125

Merged

Conversation

goofballLogic
Copy link
Contributor

@goofballLogic goofballLogic commented May 16, 2018

The cucumber reporter was showing incorrect stacktraces in situations such as when using Background steps.

In order to correct this problem, the "combined" (background + normal) set of steps for a given scenario must be stored when the TestCasePrepared event arrives from Cucumber, and then used to resolve the actual sourceLocation of the needed step, based on the index of the step being executed.

Once the sourceLocation is discovered, the actual step definition must be looked up from the gherkin feature document, rather than the scenario, because steps such as Background ones aren't contained within the current scenario's pickle.

Fixes #111
Fixes #112

@jsf-clabot
Copy link

jsf-clabot commented May 16, 2018

CLA assistant check
All committers have signed the CLA.

@christian-bromann
Copy link
Contributor

@BorisOsipov can you double check this change?

@BorisOsipov
Copy link
Contributor

BorisOsipov commented May 17, 2018 via email

Copy link
Contributor

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BorisOsipov got approval that it is working by @ringods. Merging...

thanks @goofballLogic 👍

@christian-bromann christian-bromann merged commit f2c19f3 into webdriverio-boneyard:master May 17, 2018
@BorisOsipov
Copy link
Contributor

I had quick check and for me it still fails on Scenario Outline

ERROR: Cannot read property 'steps' of undefined
phantomjs
Type    at CucumberEventListener.onTestCasePrepared (C:\Temp\wdio-cucumber4-issue\node_modules\wdio-cucumber-framework\build\cucumberEventListener.js:199:44)
    at emitOne (events.js:120:20)
    at EventEmitter.emit (events.js:210:7)
    at TestCaseRunner.emit (C:\Temp\wdio-cucumber4-issue\node_modules\wdio-cucumber-framework\node_modules\cucumber\src\runtime\test_case_runner.js:51:27)
    at TestCaseRunner.emitPrepared (C:\Temp\wdio-cucumber4-issue\node_modules\wdio-cucumber-framework\node_modules\cucumber\src\runtime\test_case_runner.js:79:10)
    at TestCaseRunner.<anonymous> (C:\Temp\wdio-cucumber4-issue\node_modules\wdio-cucumber-framework\node_modules\cucumber\src\runtime\test_case_runner.js:154:10)
    at Generator.next (<anonymous>)

See feature file example https://github.com/BorisOsipov/wdio-cucumber4-issue/blob/master/passing.feature

@goofballLogic
Copy link
Contributor Author

goofballLogic commented May 17, 2018 via email

@lrocheWB
Copy link

lrocheWB commented May 30, 2018

Still fails for me wdio-cucumber-framework@~2.1.0.

ERROR: Cannot read property 'type' of undefined
chrome
Type    at CucumberReporter.getUniqueIdentifier (integrationtests\node_modules\wdio-cucumber-framework\build\reporter.js:303:23)
    at CucumberReporter.handleBeforeStep (integrationtests\node_modules\wdio-cucumber-framework\build\reporter.js:102:27)
    at emitMany (events.js:127:13)
    at CucumberEventListener.emit (events.js:204:7)
    at CucumberEventListener.onTestStepStarted (integrationtests\node_modules\wdio-cucumber-framework\build\cucumberEventListener.js:159:18)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:191:7)
    at TestCaseRunner.emit (integrationtests\node_modules\cucumber\src\runtime\test_case_runner.js:51:27)
    at TestCaseRunner.<anonymous> (integrationtests\node_modules\cucumber\src\runtime\test_case_runner.js:135:10)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (integrationtests\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (integrationtests\node_modules\bluebird\js\release\generators.js:97:49)
    at TestCaseRunner.<anonymous> (integrationtests\node_modules\bluebird\js\release\generators.js:201:15)
    at TestCaseRunner.aroundTestStep (integrationtests\node_modules\cucumber\lib\runtime\test_case_runner.js:210:22)
    at integrationtests\node_modules\cucumber\src\runtime\test_case_runner.js:202:18
    at Generator.next (<anonymous>)
------------------------------------------------------------------
[chrome #0-0] Session ID: 6230758768436d08e2f841f802dfdcc7
[chrome #0-0] Spec: integrationtests\src\features\checkPoint\checkpoint.feature
[chrome #0-0] Running: chrome
[chrome #0-0]
[chrome #0-0] [CHECKPOINT]
[chrome #0-0]
[chrome #0-0]     Check elements
[chrome #0-0]       !! I am logged as "toto@yopmail.com" with password "tutu"
[chrome #0-0]       !! I click on the element "#validate-button"
[chrome #0-0]       !! I expect that the attribute "autofocus" from element "#code1" is "true"
[chrome #0-0]       !! I expect that element ".codes-input input" does appear exactly "6" times
[chrome #0-0]       !! I expect that element "body" contains the text "Code de ..."
[chrome #0-0]
[chrome #0-0]         Errors
[chrome #0-0]
[chrome #0-0]             Cancel
[chrome #0-0]
[chrome #0-0]
[chrome #0-0] 5 pending (6s)
[chrome #0-0]

Scenario:

Feature: [CHECKPOINT]

  Background:
    Given I execute special request "/url"

  Scenario: Check elements
    When I am logged as "toto@yopmail.com" with password "tutu"
    And I click on the element "#validate-button"
    Then I expect that the attribute "autofocus" from element "#code1" is "true"
    And I expect that element ".codes-input input" does appear exactly "6" times
    And I expect that element "body" contains the text "Code de ..."

  Scenario: Errors
    When I click on the element "#validate-button"
    And I click on the element "#validate-button"
    Then I expect that element "body" contains the text "Veuillez saisir ..."

    When I set "9" to the inputfield "#code1"
    And I set "9" to the inputfield "#code2"
    And I set "9" to the inputfield "#code3"
    And I set "9" to the inputfield "#code4"
    And I set "9" to the inputfield "#code5"
    And I set "9" to the inputfield "#code6"
    And I click on the element "#validate-button"
    And I wait on element "#globalError" for 10000ms to be visible
    And I pause for 1000ms
    Then I expect that element "body" contains the text "Le code ..."

    When I set "t" to the inputfield "#code1"
    Then I expect that element "#code1" is empty

  Scenario: Cancel
    When I click on the element "#validate-button"
    And I click on the element "#validate-button"
    And I click on the element "#cancel-button"
    Then I expect that the url is "http://url"

I am the only one to reproduce the problem ?
the error appears on all scenarios using the keyword background.

@lrocheWB
Copy link

lrocheWB commented May 30, 2018

I have the same issue as @BorisOsipov:

ERROR: Cannot read property 'steps' of undefined
chrome
Type    at CucumberEventListener.onTestStepPrepared (integrationtests\node_modules\wdio-cucumber-framework\build\cucumberEventListener.js:186:44)
    at emitOne (events.js:101:20)
[...]
------------------------------------------------------------------
[chrome #0-16] Session ID: a9758084af4f82afac38fda1bac8d97a
[chrome #0-16] Spec: integrationtests\src\features\login\connectWithAccessToken.feature
[chrome #0-16] Running: chrome
[chrome #0-16]
[chrome #0-16] [LOGIN]
[chrome #0-16]
[chrome #0-16]     login with accessToken By url & by header
[chrome #0-16]
[chrome #0-16]         login with accessToken By url & by header
[chrome #0-16]
[chrome #0-16]
[chrome #0-16]

Scenario:

  Scenario Outline: login with accessToken By url & by header
    Given I generate the global "<userType>" accessToken with username "<username>" and password "<currentPassword>"
    When I open "/fo/v1/user/show" with generated Access Token sent by url
[...]

How to fix this ?

@christian-bromann
Copy link
Contributor

@lrocheWB there is a pending PR with a fix

@martinotu
Copy link

Hi all,
I am facing the same issue after updating to "wdio-cucumber-framework": "2.1.0".
Any update?

@wynnfarm
Copy link

@martinotu I'm in the same boat.

ERROR:` Cannot read property 'steps' of undefined
internetexplorer
Type    at CucumberEventListener.onTestStepPrepared (C:\DEV\ember\home-ui\node_modules\wdio-cucumber-framework\build\cucumberEventListener.js:186:45)
    at emitOne (events.js:121:20)
    at EventEmitter.emit (events.js:211:7)
    at TestCaseRunner.emit (C:\DEV\ember\home-ui\node_modules\cucumber\lib\runtime\test_case_runner.js:94:29)
    at TestCaseRunner.emitPrepared (C:\DEV\ember\home-ui\node_modules\cucumber\lib\runtime\test_case_runner.js:127:12)
    at TestCaseRunner.<anonymous> (C:\DEV\ember\home-ui\node_modules\cucumber\lib\runtime\test_case_runner.js:219:14)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (C:\DEV\ember\home-ui\node_modules\cucumber\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (C:\DEV\ember\home-ui\node_modules\cucumber\node_modules\bluebird\js\release\generators.js:97:49)
    at TestCaseRunner.<anonymous> (C:\DEV\ember\home-ui\node_modules\cucumber\node_modules\bluebird\js\release\generators.js:201:15)
    at TestCaseRunner.run (C:\DEV\ember\home-ui\node_modules\cucumber\lib\runtime\test_case_runner.js:236:22)
    at Runtime.<anonymous> (C:\DEV\ember\home-ui\node_modules\cucumber\lib\runtime\index.js:113:51)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (C:\DEV\ember\home-ui\node_modules\cucumber\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (C:\DEV\ember\home-ui\node_modules\cucumber\node_modules\bluebird\js\release\generators.js:97:49)
    at Runtime.<anonymous> (C:\DEV\ember\home-ui\node_modules\cucumber\node_modules\bluebird\js\release\generators.js:201:15)

@meskis
Copy link

meskis commented Jun 13, 2018

Same here, can't develop testing framework due to this. Any updates? ;)

@BorisOsipov
Copy link
Contributor

For all questions above and onward
Feel free to help implement #126
if you want to have the fix for that.

@fawol01o
Copy link

Any Update Please

@jmsuda
Copy link

jmsuda commented Jun 14, 2018

Same problem for me.

@hk2225
Copy link

hk2225 commented Jun 14, 2018

Any update on this issue (wdio-cucumber-framework@~2.1.0.)?
ERROR: Cannot read property 'type' of undefined
chrome
Type at CucumberReporter.getUniqueIdentifier

@woolter
Copy link
Contributor

woolter commented Jun 19, 2018

I found another bug related to the same, when I use background in the terminal shows the steps in green (as completed) as soon as start, and if the step definition has a function that validates more than one thing or action, it doesn't execute them, execute just the first one, but the scenario doesn't fail.
If I delete background works as expected.

@kapilchokhawala
Copy link

+1 for this issue

@worc
Copy link

worc commented Jul 5, 2018

merged but nothing has been fixed? this error is still occurring. there's definitely something severely wrong here. the test scenarios seem to be nesting into each other instead of being a flat list.

@christian-bromann
Copy link
Contributor

please see #126

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

Successfully merging this pull request may close these issues.

Still failure in cucumber before/after hooks reporters Scenario Outline is not working