webdriverio-boneyard / wdio-cucumber-framework

A WebdriverIO v4 plugin. Adapter for Cucumber testing framework.
MIT License
77 stars 61 forks source link

tags at Example causing exception #162

Closed jonn-set closed 5 years ago

jonn-set commented 5 years ago

I am using wdio-cucumber-framework with cucumber 4 and have seen that passing tag expression that includes tags at Example level is not getting filtered, instead it end up throwing an exception.

If I pass a tag expression of @F1 and @Sc01 and @ex01, it will throw the below exception:

Error

ERROR: Cannot read property 'steps' of undefined
chrome
Type    at CucumberEventListener.onTestCasePrepared (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/build/cucumberEventListener.js:211:45)
    at emitOne (events.js:121:20)
    at EventEmitter.emit (events.js:211:7)
    at TestCaseRunner.emit (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/node_modules/cucumber/lib/runtime/test_case_runner.js:94:29)
    at TestCaseRunner.emitPrepared (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/node_modules/cucumber/lib/runtime/test_case_runner.js:127:12)
    at TestCaseRunner.<anonymous> (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/node_modules/cucumber/lib/runtime/test_case_runner.js:219:14)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (/Users/john/workspace/sample/node_modules/bluebird/js/release/util.js:16:23)
    at PromiseSpawn._promiseFulfilled (/Users/john/workspace/sample/node_modules/bluebird/js/release/generators.js:97:49)
    at TestCaseRunner.<anonymous> (/Users/john/workspace/sample/node_modules/bluebird/js/release/generators.js:201:15)
    at TestCaseRunner.run (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/node_modules/cucumber/lib/runtime/test_case_runner.js:236:22)
    at Runtime.<anonymous> (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/node_modules/cucumber/lib/runtime/index.js:113:51)
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (/Users/john/workspace/sample/node_modules/bluebird/js/release/util.js:16:23)
    at PromiseSpawn._promiseFulfilled (/Users/john/workspace/sample/node_modules/bluebird/js/release/generators.js:97:49)
    at Runtime.<anonymous> (/Users/john/workspace/sample/node_modules/bluebird/js/release/generators.js:201:15)
    at Runtime.runTestCase (/Users/john/workspace/sample/node_modules/wdio-cucumber-framework/node_modules/cucumber/lib/runtime/index.js:123:22)
    at tryCatcher (/Users/john/workspace/sample/node_modules/bluebird/js/release/util.js:16:23)
    at Object.gotValue (/Users/john/workspace/sample/node_modules/bluebird/js/release/reduce.js:155:18)
    at Object.gotAccum (/Users/john/workspace/sample/node_modules/bluebird/js/release/reduce.js:144:25)
    at Object.tryCatcher (/Users/john/workspace/sample/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/john/workspace/sample/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/john/workspace/sample/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromiseCtx (/Users/john/workspace/sample/node_modules/bluebird/js/release/promise.js:606:10)
    at _drainQueueStep (/Users/john/workspace/sample/node_modules/bluebird/js/release/async.js:142:12)
    at _drainQueue (/Users/john/workspace/sample/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/john/workspace/sample/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues (/Users/john/workspace/sample/node_modules/bluebird/js/release/async.js:17:14)

My feature file

@F1
Feature: Feature 1

  @Sc01
  Scenario Outline: Some Outline

    Given On "<arg01>" website, I enter "<arg02>"

  @ex01
    Examples:
      | arg01  | arg02 |
      | google | blah  |

  @ex02
    Examples:
      | arg01  | arg02 |
      | google | blah  |
      | bing   | blah  |

  @ex03
    Examples:
      | arg01      | arg02 |
      | duckduckgo | blah  |

If I remove the @ex01 tag then it will work and the test runs. I was using cucumber 1 and compatible wdio-cucumber-framework earlier with the old type tags and it use to work without any issues

jonn-set commented 5 years ago

@BorisOsipov Can you review this and merge it please?

jonn-set commented 5 years ago

Hi, its been 2 months, appreciate you guys are busy but can someone have a look at this merge request please?

BorisOsipov commented 5 years ago

@jonn-set would you mind adding unit test for this?

jonn-set commented 5 years ago

@BorisOsipov, sure, will do.

I ran through the existing tests and was wondering if there's a way to check that the right number of scenarios have been picked up using CucumberAdapter. It looks like all the tests call run function to execute the tests, which only return 0 or 1, is there something else that I can use as I don't really need to run the whole test, just make sure the right scenarios are filtered for testing.

Thanks

BorisOsipov commented 5 years ago

@jonn-set I am not ready to drive deep into current testing suite. I would like to have corresponding test at least to make sure we won't have regression in future with this fix

jonn-set commented 5 years ago

@BorisOsipov I have added some unit tests, have a look and if you are happy with it, please merge.

Thank you

jonn-set commented 5 years ago

@BorisOsipov, thanks for merging, when will this be released?

BorisOsipov commented 5 years ago

@christian-bromann ping

jonn-set commented 4 years ago

@christian-bromann, was this released?