webdriverio-boneyard / wdio-cucumber-framework

A WebdriverIO v4 plugin. Adapter for Cucumber testing framework.
MIT License
77 stars 61 forks source link

Wrong execution order in afterStep/afterScenario #151

Closed woolter closed 5 years ago

woolter commented 6 years ago

With this configuration

beforeScenario: function(scenario) {
    console.log(scenario.name);
  },
afterStep: function(stepResult) {
    console.log('Status:', stepResult.status);
    if (stepResult.status === 'failed') {
      browser.saveScreenshot(
        './errorShots/' +
          stepResult.feature +
          '_' +
          stepResult.scenario +
          '_' +
          stepResult.text +
          '.png'
      );
      console.log('Screenshot created');
    }
  },
afterScenario: function(scenario) {
    console.log(scenario.name);
  },

I hope to obtain this:

GOOGLE
Status: passed
Status: passed
GOOGLE
YANDEX
Status: passed
Status: failed
Screenshot created
Status: skipped
YANDEX

But sometimes I obtain this: with image created

GOOGLE
Status: passed
Status: passed
GOOGLE
YANDEX
Status: passed
Status: failed
Status: skipped
YANDEX
Screenshot created

And sometimes this: without create image

GOOGLE
Status: passed
Status: passed
GOOGLE
YANDEX
Status: passed
Status: failed
Status: skipped
YANDEX
NaveenThiyagarajan commented 5 years ago

@christian-bromann This is the issue i was talking about in ticket https://github.com/webdriverio/webdriverio/issues/3074 The issue is seen in the latest wdio-cucumber-framework.

This issue is not in the version wdio-cucumber-framework: 1.0.3. I have a project and confirmed.

I have created a sample git project for you to reproduce the isuse: https://github.com/NaveenThiyagarajan/wdio_cuke_hookIssue.git

Thanks. Naveen

BorisOsipov commented 5 years ago

@NaveenThiyagarajan see my comment in https://github.com/webdriverio/webdriverio/issues/3068#issuecomment-444011064

it will help you.

NaveenThiyagarajan commented 5 years ago

Thanks @BorisOsipov I tried using the cucumber default hooks

After(() => {
    if(Status.FAILED === 'failed'){
        browser.screenshot().value;
        console.log('Screenshot taken');
    }
});

... But the allure-reporter was acting up weird with that .. :( it was showing skipped tests as passed.

BorisOsipov commented 5 years ago

... But the allure-reporter was acting up weird with that .. :( it was showing skipped tests as passed.

I haven't seen such issue in allure repo...

NaveenThiyagarajan commented 5 years ago

... But the allure-reporter was acting up weird with that .. :( it was showing skipped tests as passed.

I haven't seen such issue in allure repo...

Ok .. I got it.. It fixed once i moved to 0.8.3 allure-reporter. Thank you.. good for now.