Cucumber-js: “cucumberOpts”参数发生了什么变化? 是不是已经不支持了?

创建于 2017-06-06  ·  5评论  ·  资料来源: cucumber/cucumber-js

这个问题是这个https://github.com/angular/protractor/issues/4311的延续。 我正在讨论有关如何使用量角器执行 Cucumberjs 脚本的语法更改的地方。

根据@wswebcreation https://github.com/wswebcreation 的要求,我关闭了另一个问题并在此处打开了一个新问题。

所以,我最后的评论是这样的......

我最后一次成功执行的记录是 2017 年 5 月 12 日 14:03。 正是文档中的日期。

您关于标签的示例非常简单......我应该如何调用 3 个标签,两个必须执行,一个被忽略。 在 5 月 12 日之前,这曾经可以正常工作,但现在不行:

protractor ./FM_IntTest_UI_conf.js --disableChecks [email protected] --params.login.passw=mypassword --cucumberOpts.tags ~<strong i="13">@ignore</strong> --cucumberOpts.tags <strong i="14">@smoke</strong>,@sprint

您的文档现在说它应该是这样的,但不起作用,返回与我随“票”一起提交的相同错误消息。

protractor ./FM_IntTest_UI_conf.js --disableChecks [email protected] --params.login.passw=mypassword --cucumberOpts.tags '<strong i="18">@smoke</strong> or <strong i="19">@rt</strong>' --cucumberOpts.tags 'not <strong i="20">@ignore</strong>'

错误:错误:指定了多个配置文件
在 C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\built\cli.js:155:15
在 C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\node_modules\optimist\index.js:307:21
在 Array.forEach(本机)
在 parseArgs (C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\node_modules\optimist\index.js:305:16)
在 Object.Argv.self.parse (C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\node_modules\optimist\index.js:140:16)
在对象。 (C:\Users\echavez\AppData\Roaming\npm\node_modules\protractor\built\cli.js:158:21)
在 Module._compile (module.js:571:32)
在 Object.Module._extensions..js (module.js:580:10)
在 Module.load (module.js:488:32)
在 tryModuleLoad (module.js:447:12)

我可以在 Cucumber 文档中看到,步骤定义的编码语法也发生了变化? 为什么现在让它变得更复杂? 因为使用新语法,我必须按场景对步骤进行分组。 但是有一些步骤在几个场景中重复,从而在每个场景上重复代码? 我的代码最终会出现冗余。 为什么?

这是我现在在 test.spec.js 文件中的片段:

this.Given('I am testing my Widget Application', function (callback) {
    edirp.edirejectwidgetlink.click().then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('ERROR: Widget button not found');
        callback(reason);
    });
});

this.When('There are records in the Widget List', function() {
    edirp.edigetrow.count().then(function(cnt){
        if(cnt>0){
            return recordsFound = cnt;
        }else{
            return recordsFound = 0;
        }
    });
});


this.Then('Header name of the Widget List is '(.+)'', function(header, callback) {
    expect(po.headertext.getText()).to.eventually.equal(header).then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('Warning: Incorrect Text.');
        callback(reason);
    });
});

这是建议作为“更新”的片段......对我来说是降级:

var seleniumWebdriver = require('selenium-webdriver');
var {defineSupportCode} = require('cucumber');

defineSupportCode(function({Given, When, Then}) {
  Given('I am testing my Widget Application', function (callback) {
    edirp.edirejectwidgetlink.click().then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('ERROR: Widget button not found');
        callback(reason);
    });

  When('There are records in the Widget List', function() {
    edirp.edigetrow.count().then(function(cnt){
        if(cnt>0){
            return recordsFound = cnt;
        }else{
            return recordsFound = 0;
        }
    });
  Then('Header name of the Widget List is '(.+)'', function(header, callback) {
    expect(po.headertext.getText()).to.eventually.equal(header).then(function(){ 
        callback();
    }).catch(function(reason) {
        console.log('Warning: Incorrect Text.');
        callback(reason);
    });
});

如果场景有几个 Given, When, Then... 是否必须在这里枚举,像这样?:
defineSupportCode(function({Given, And, And, When, And, And, Then, And, And, And}) {

如果这是真的......那么现在,如果我想在我的功能的另一个场景中再次使用“当有记录在 EDI-Rejects 小部件中时”步骤,我是否需要再次对所有功能进行编码?

我需要的只是带有论据的答案。 不要把它当作个人。

所有5条评论

如果场景有几个 Given, When, Then... 是否必须在这里枚举,像这样?:
defineSupportCode(function({Given, And, And, When, And, And, Then, And, And, And}) {

不。 GivenWhenThen是可以多次调用的函数(类似于 1.x 中的this.Given等)。 And不是函数。 您可以在API 参考中看到defineSupportCode传递的所有函数,该参考链接来自README.md

我可以在 Cucumber 文档中看到,步骤定义的编码语法也发生了变化?

https://github.com/cucumber/cucumber-js/issues/679

为什么现在让它变得更复杂? 因为使用新语法,我必须按场景对步骤进行分组。

那不是真的

谢谢我去看看!

@charlierudolph Tnx 的解释!

由于关闭后没有任何近期活动,因此该线程已自动锁定。 请为相关错误打开一个新问题。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

jfstephe picture jfstephe  ·  4评论

protoman92 picture protoman92  ·  3评论

edwinwright picture edwinwright  ·  3评论

NoNameProvided picture NoNameProvided  ·  5评论

pellekrogholt picture pellekrogholt  ·  3评论