0

Please help on this. I am using the following cucumber opts:

cucumberOpts: {
    backtrace: false,
    failAmbiguousDefinitions: true,
    failFast: false,
    ignoreUndefinedDefinitions: false,
    name: [],
    snippets: true,
    source: true,
    profile: [],
    require: [
        './features/step_definitions/given.js',
        './features/step_definitions/when.js',
        './features/step_definitions/then.js',
    ],
    snippetSyntax: undefined,
    strict: true,
    tagExpression: '@Test',
    tagsInTitle: false,
    timeout: 20000000,
},
AS Mackay
  • 2,831
  • 9
  • 19
  • 25
akhilesh qa
  • 21
  • 1
  • 2

4 Answers4

1

https://www.npmjs.com/package/wdio-rerun-service Was recently released specifically for WebdriverIO and it works well with Cucumber Features/Scenarios.

mikesalvia
  • 101
  • 5
0

I'm assuming you're using the wdio-cucumber-framework then you can only rerun individual steps a specific number of times, like so:

module.exports = function () {
    /**
     * The following STEP DEFINITION will run maximum 3 times!
     * => 1 actual run + 2 reruns (on failure)
     */
    this.Given(/^Your step definition here$/, { wrapperOptions: { retry: 2 } }, () => {
        // ...
    });
});

!Note: wrapperOptions are step-specific options that are passed to the definition function wrapper. In our case, the retry option. You can read more about it in the Cucumber DOCS.

If you need control over the retry of a test-case, or test-suite, then unfortunately there isn't such a feature yet with Cucumber. But, if you want something like that, maybe use Mocha instead. Here are a few examples.

iamdanchiv
  • 4,052
  • 4
  • 37
  • 42
0

Add this code to your wdio config file. It will retry the fail test two more time (total 3 time)

specFileRetries: 2,
specFileRetriesDelay: 5,
specFileRetriesDeferred: false,
0

In wdio.conf.js set following we are good to go, this configuration will rerun failed scenario from the beginning not just the failed step.

 runnerConfig: {
    // Set the number of times to retry a failed scenario
    retry: 2,
  },

then

cucumberOpts: {
    retry: true,
  },
Mahadev Gouda
  • 769
  • 11
  • 14