使用Protractor-multiple-cucumber-html-reporter-plugin时,我们可以在html报表生成中打印使用的测试数据吗?

时间:2019-08-27 06:37:56

标签: protractor automated-tests cucumber e2e-testing cucumberjs

我正在使用量角器黄瓜框架进行自动化测试。 我正在使用Protractor-multiple-cucumber-html-reporter-plugin生成报告。 我们可以在报告中使用打印测试数据吗? 要么 至少,我们可以在显示错误消息的报告中打印故障测试用例的测试数据吗?

1 个答案:

答案 0 :(得分:0)

是的,可以。将您的测试数据推送到Buffer(缓冲),这是一个节点js概念,并将其附加到如下所示的hooks文件中的this.world

   After(async function () {
    const userDetails = Buffer.from(JSON.stringify(Shared.userDetails));
    await this.World.attach(userDetails, 'application/json');
    const testData = Buffer.from(JSON.stringify(Shared.testDataObj));
    await this.World.attach(testData, 'application/json');
});

最后,黄瓜将从this.world获取全部数据,并将其存储在Cucumber-json-report.json中,我们将使用它在Cucumber-html-reporter的帮助下生成报告。