admin管理员组文章数量:1389761
I would like to print the status of each cucumber scenario using the afterScenario hook.
I've tried printing out scenario.status (code below) but it prints out "undefined"
afterScenario: (scenario) => {
console.log(scenario.status);
}
When printing out just scenario, I don't see status.
Scenario {
feature:
Feature {
description: undefined,
keyword: 'Feature',
line: 1,
name: 'Sample Test',
tags: [],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
scenarios: [ [Circular] ] },
keyword: 'Scenario',
lines: [ 15, 7 ],
name: 'Getting test status',
tags:
[ Tag { line: 6, name: '@WIP' }],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
line: 15,
description: undefined,
steps:
[ Step {
arguments: [],
line: 4,
name: 'I am on the app',
scenario: [Circular],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
isBackground: true,
keyword: 'Given ',
keywordType: 'precondition' },
Step {
arguments: [],
line: 8,
name: 'I am viewing the splash screen',
scenario: [Circular],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
isBackground: false,
keyword: 'Given ',
keywordType: 'precondition' } ] }
I had a read through which suggested (from my understanding) to do scenario.failed, but I still get undefined. Would anyone be able to tell me how I can get the status of a scenario?
I am using cucumber v3.2.1 and wdio-cucumber-framework v1.0.3.
I would like to print the status of each cucumber scenario using the afterScenario hook.
I've tried printing out scenario.status (code below) but it prints out "undefined"
afterScenario: (scenario) => {
console.log(scenario.status);
}
When printing out just scenario, I don't see status.
Scenario {
feature:
Feature {
description: undefined,
keyword: 'Feature',
line: 1,
name: 'Sample Test',
tags: [],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
scenarios: [ [Circular] ] },
keyword: 'Scenario',
lines: [ 15, 7 ],
name: 'Getting test status',
tags:
[ Tag { line: 6, name: '@WIP' }],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
line: 15,
description: undefined,
steps:
[ Step {
arguments: [],
line: 4,
name: 'I am on the app',
scenario: [Circular],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
isBackground: true,
keyword: 'Given ',
keywordType: 'precondition' },
Step {
arguments: [],
line: 8,
name: 'I am viewing the splash screen',
scenario: [Circular],
uri: '/Users/Daredevil/e2e/features/sampleProject/intro.feature',
isBackground: false,
keyword: 'Given ',
keywordType: 'precondition' } ] }
I had a read through https://docs.cucumber.io/cucumber/api/#hooks which suggested (from my understanding) to do scenario.failed, but I still get undefined. Would anyone be able to tell me how I can get the status of a scenario?
I am using cucumber v3.2.1 and wdio-cucumber-framework v1.0.3.
Share Improve this question edited Oct 16, 2018 at 7:09 Daredevi1 asked Oct 10, 2018 at 17:03 Daredevi1Daredevi1 1033 silver badges13 bronze badges3 Answers
Reset to default 2Answer is simple, you should be console logging "scenario.result.status" instead of scenario.status.
Hope this answer helps you!
Below should work- (tried with wdio-cucumber)
After(function (scenarioResult) {
const scenario = scenarioResult.scenario;
console.log('SCENARIO EXECUTION COMPLETED:',scenario.name);
});
This is not an answer just a suggestion. I would look into how the report.json is built as that report has all the scenarios and their result.
Another pointer is in your cucumber.js file set the reporting format you want to progress which will output progress to the console.
Take a look at https://github./cucumber/cucumber-js/blob/master/docs/cli.md#Formats
本文标签: Javascript consolelog status of Cucumber scenarioStack Overflow
版权声明:本文标题:Javascript console.log status of Cucumber scenario - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669438a2618736.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论