当使用cucumberopts格式作为Json时,浏览器立即关闭量角器黄瓜测试

问题描述 投票:1回答:2

我正在运行Protractor黄瓜测试并试图使用量角器 - 多重黄瓜-html-报告插件生成报告。

但是当我在配置文件中使用format:json:result.json时,浏览器(chrome)会在测试开始运行后立即关闭,并显示报告中传递的所有测试用例。

但是我以这样的方式编写了场景,一些测试用例应该失败。这只发生在我使用format:jason:result.json在cucumberOpts中。

当我使用格式:'漂亮'时,浏览器工作正常,它显示所有测试用例的运行,并且它还显示正确数量的测试用例通过和失败。

请找我的配置文件

const path = require('path');
exports.config = {
directConnect: true,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
    require: [
         'maths.js',
    ],
    // Tell CucumberJS to save the JSON report
    format: 'json:.tmp/results.json',
    strict: true
},

specs: [
    '*.feature'
],

multiCapabilities: [{
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2,
    chromeOptions: {
        args: ['disable-infobars']
    }
}],

// Here the magic happens
plugins: [{
    package: 'protractor-multiple-cucumber-html-reporter-plugin',
    options:{
         automaticallyGenerateReport: true,
         removeExistingJsonReportFile: true
    }
}]

};

json testing protractor cucumber report
2个回答
0
投票

当您在一个步骤中调用callback()函数时,黄瓜会执行该步骤但等待量角器完成它。量角器以异步方式运行,因此您必须构建以下步骤:

this.Then(/^I title contains angularjs$/, function () {
    // Write code here that turns the phrase above into concrete actions
    return browser.getCurrentUrl().then(function (text) {
      expect(text).to.eventually.contains('nonAngular');
    })
  });

你还需要添加cucumberOpts:

require: "./path/to/step_definition/*.js",

0
投票

尝试将以下内容添加到conf.js解决了我的问题

onPrepare: function () {        
    browser.ignoreSynchronization = true;       
    browser.waitForAngular();           
    browser.driver.manage().timeouts().implicitlyWait(30000);       
}
© www.soinside.com 2019 - 2024. All rights reserved.