2017-09-21 28 views
1

我正在运行量角器黄瓜测试并尝试使用量角器多重cucumber-html-reporter-plugin生成报告。浏览器立即在量角器黄瓜测试中关闭,当使用cucumber作为Json

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

但我写了这样的情况下,一些测试用例应该失败。这只发生在我使用格式:json:result.json在cucumberOpts。

当我使用format:'pretty'时,浏览器正常工作,它显示所有测试用例的运行情况,并且它显示正确数量的测试用例已通过并失败。

请找我的配置文件

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 
    } 
}] 

};

+0

黄瓜什么版本您使用的? – Razvan

+0

黄瓜1.3.2。我也尝试过黄瓜2 – doe

+0

你可以添加一些步骤定义吗?我认为问题在于你已经实施了这些步骤。 – Razvan

回答

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", 
相关问题