Is there a way to continue running the test script after the step in the previous script failed?

Whenever a step fails while running on a remote server, I would like to capture the failed step and continue with the remaining scripts. The captured step will then be included in the file for reporting purposes. Is it possible? All the answers I've seen elsewhere, just say you should correct the test before moving on. I agree, but I want the tests to stop when run locally, not remotely.

➜ customer git:(pat104) ✗ cucumber.js -f progress (pat104⚡) ...F-----Failed scenario: View and select first contact from contact history ...F-Failed scenario: View and select a contact from multiple contacts in history ..................................................F---Failed scenario: Navigating to profile with url and enrollmentId ...................................................F-Failed scenario: Successful MDN Search with 1 result returned. Tech Selects and continues .............FFailed scenario: Successful MDN with multiple results

+3


source to share


3 answers


It turns out that one of the step definitions was using .waitForExist incorrectly. The test was written:

this.browser
        .waitForExist('#someElement', 1000, callback)

      



Callback is not a parameter for .waitForExist, rewritten to:

.waitForExist('#someElement',1000).then(function (exists) {
            assert.equal(exists, true, callback);
        })

      

+3


source


This is the default behavior, isn't it? Example command



cucumber.js -f json > cucumberOutput.json

      

0


source


Good thing you need to manage in your test using callback.fail(e)

as below. You can use a library like grunt-cucumberjs to add these errors to good HTML reports.

this.Then(/^the save to wallet button reflects the offer is saved$/, function (callback) {
        merchantPage(this.nemo).doStuff().then(function () {
            callback();
        }, function (e) {
            callback.fail(e); //add this to report
        });
});

      

Or you can use Hooks and check if the script failed and report (take a screenshot or add a log, etc.)

 this.After(function (scenario, callback) {
        var driver = this.nemo.driver;
        if(scenario.isFailed()){
            driver.takeScreenshot().then(function (buffer) {
                scenario.attach(new Buffer(buffer, 'base64').toString('binary'), 'image/png');
            });
        }
        driver.quit().then(function () {
                callback();
       });
 });

      

0


source







All Articles