webdriverio icon indicating copy to clipboard operation
webdriverio copied to clipboard

webdriverio 3.2.x to expose scenario tags, feature description, etc to spec reporter

Open melwynfurtado opened this issue 10 years ago • 8 comments

We are using webdriverio V3.2.x with spec reporter. Industry I work in is highly regulated and we need to document all automation test results output before every release. So it is quite essential that all test output is pretty formatted and passed on from feature files to test output files.

Right now, I can't get all information from my feature files to my hooks or custom reporter as its not being exposed by frameworks/cucumber.js methods like handleBeforeFeatureEvent or handleBeforeScenarioEvent.

Here is example of one of the hooks I am using for getting scenario tags...

var CukeHooks = function () {
  this.BeforeScenario(function (event, callback) {
    var tags = event.getPayloadItem('scenario').getTags().map(function(tag) {
      return tag.getName();
    });
    console.log('  ' + tags.join(' '));
    callback();
  });
};
module.exports = CukeHooks;

Do you accept commits to one of the older releases or is it exposed in latest release?

melwynfurtado avatar Mar 21 '16 11:03 melwynfurtado

In v4 you will have more opportunity to get more information on the test data. There you have beforeFeature hooks giving you data about the current running feature. Same for scenarions and steps. We are about to official release v4 this week so it might be a good idea to start with it already.

christian-bromann avatar Mar 21 '16 11:03 christian-bromann

Cheers @christian-bromann. I will wait for V4 release.

melwynfurtado avatar Mar 21 '16 12:03 melwynfurtado

Hey Chris so now that we are on v4 whats the right way to get feature/scenario/steps definitions?

tripleratamacue avatar Apr 20 '17 00:04 tripleratamacue

@tripleratamacue please have a look at our cucumber boilerplate projects

christian-bromann avatar Apr 20 '17 06:04 christian-bromann

Thanks for replying Chris I do see tags example, but my concern its how get feature, scenario and step details, I don't see any of those examples in that project, correct me if this is not the one: https://github.com/webdriverio/cucumber-boilerplate/blob/master/wdio.conf.js

tripleratamacue avatar Apr 20 '17 21:04 tripleratamacue

how get feature, scenario and step details

What do you mean by that?

christian-bromann avatar Apr 20 '17 21:04 christian-bromann

Scenario title, this is some code I currently but it show errors: afterScenario: function (stepResult) { feature = stepResult.getPayloadItem('feature'); scenario = stepResult.getPayloadItem('scenario');

    scenario = this.stepResult.getScenario().getName();
    step = this.stepResult.getStep().getName();
    console.log('Last ran step: ' + step);

} https://github.com/cucumber/cucumber-js/issues/200

tripleratamacue avatar Apr 20 '17 21:04 tripleratamacue

Chris? Am I able to explain my self? :)

tripleratamacue avatar Apr 27 '17 05:04 tripleratamacue