【问题标题】:Is it possible to append (rather than overwrite) cucumberOpt.tagExpressions in the command line?是否可以在命令行中附加(而不是覆盖)cucumberOpt.tagExpressions?
【发布时间】:2018-08-28 11:00:36
【问题描述】:

我有使用 cucumber 和 wdio 运行的硒测试。 我的 wdio.conf.js 文件如下所示:

cucumberOpts: {
    tagExpression: 'not @ignore',
},

我有已标记的测试

@cats
Scenario: As a user I want to google cats
Given I have google open
When I type in 'cats'
And then I see pictures of cats

@dogs
Scenario: As a user I want to google dogs
Given I have google open
When I type in 'dogs'
And then I see pictures of dogs

@dogs @ignore
Scenario: As a user I want to google fierce dogs
Given I have google open
When I type in 'fierce dogs'
And then I see pictures of fierce dogs

如果我想运行所有未被忽略的狗测试,我可以运行:

 ./node_modules/.bin/wdio wdio.conf.js --cucumberOpts.tagExpression='@dogs and not @ignore'

我想做的就是跑

./node_modules/.bin/wdio wdio.conf.js --cucumberOpts.tagExpression='@dogs'

(或类似的)从命令行并让它从 wdio.conf.js 文件中获取“not @ignore”。

可以这样做吗?

【问题讨论】:

    标签: cucumber webdriver-io


    【解决方案1】:

    绝对有可能;不过,您确实必须为此编写一些代码。假设您安装了“yargs”,您可以执行以下操作:

    const argv = require('yargs').argv;
    
    let tags = '(not @pending)';
    
    if (argv.tags) {
      tags += ` and (${argv.tags})`
    }
    
    // ...rest of configs
    
    cucumberOpts: {
        tagExpression: tags
    },
    

    然后你会运行它: ./node_modules/.bin/wdio wdio.conf.js --tags='@dogs'

    请注意,我尚未测试此特定代码,因此希望没有语法错误。

    【讨论】:

      猜你喜欢
      • 2022-11-23
      • 2017-10-22
      • 2020-07-01
      • 2011-04-02
      • 2019-03-02
      • 2011-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多