我有使用黄瓜和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”。
可以这样做吗?
答案 0 :(得分:0)
这绝对有可能;您确实需要为此编写一些代码。假设您已安装“ 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'
请注意,我尚未测试此特定代码,因此希望不会出现语法错误。