Cucumber-js: 如何在第一次失败时停止测试运​​行?

创建于 2016-07-06  ·  7评论  ·  资料来源: cucumber/cucumber-js

我需要在发现第一个失败时停止测试,我也在使用 Protractor。 我创建了:

    this.After(function (scenario, callback) {
        if (scenario.isFailed()) {
            browser.takeScreenshot().then(function(png) {
                var decodedImage = new Buffer(png, 'base64').toString('binary');
                scenario.attach(decodedImage, 'image/png');
                browser.quit();
                callback();
            });
        } else {
            callback();
        }
    });

但我一点也不喜欢这种方法! 问题是,对于其余的场景,如果其他团队成员看到它,我会遇到一个令人困惑的错误! 你能帮我吗? 我环顾四周,没有发现任何东西!

谢谢

最有用的评论

cucumber-js 有一个--fail-fast CLI 选项,它将在第一次失败后停止测试运​​行。

所有7条评论

cucumber-js 有一个--fail-fast CLI 选项,它将在第一次失败后停止测试运​​行。

我试过了,但似乎没有工作,我有一个npm task"e2e-local": "scripts/test-e2e.sh local"执行: grunt test:e2e:"$1" --tags "$2"和 grunt 文件中的量角器任务看起来像:

      // Functional test configuration
        protractor: {
            options: {
                configFile: 'test/protractor-devel-conf.js',
                keepAlive: false,
                noColor: false,
                args: {
                    cucumberOpts: {
                        tags: grunt.option('tags')
                    }
                }
            },
            local: {
                options: {
                    configFile: 'test/protractor-devel-conf.js',
                    keepAlive: false
                }
            },
            live: {
                options: {
                    configFile: 'test/protractor-live-conf.js',
                    keepAlive: false
                }
            }
        },

我曾尝试在所有调用点添加--fail-fast ,例如:

  • npm run e2e-local --tags <strong i="14">@TAG</strong> --fail-fast并没有工作
  • grunt test:e2e:"$1" --tags "$2" --fail-fast但都没有...

我看不出我做错了什么! 你能告诉!?

我相信你实际上应该在你正在使用的 grunt 插件的 repo 上问这个问题。 我的预感是您需要在配置中的 cucumberOpts 块中添加一些内容。

@bmsok​​o 对此有何更新? 如果不打算关闭它

由于不活动而关闭。 如果需要请重新打开

@charlierudolph非常感谢您的回复! 我还没有就这个问题联系过 grunt 插件开发人员,但很快就会联系并让你知道。

该线程已被自动锁定,因为它关闭后没有任何最近的活动。 请针对相关错误打开一个新问题。

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