yahoo / protractor-retry

Use protractor features to automatically re-run failed tests with a specific configurable number of attempts.
MIT License
28 stars 32 forks source link

When we using Protractor-retry then it Re-run whole test case not a failed test cases #62

Open Navneetsoni860 opened 5 years ago

Navneetsoni860 commented 5 years ago

Can someone help me on this..... My conf file : var retry = require('../lib/retry');

exports.config = { framework: 'jasmine2', specs: ['./jasmine/*.spec.js'], jasmineNodeOpts: { // If true, print colors to the terminal. showColors: true, // Default time to wait in ms before a test fails. defaultTimeoutInterval: 30000 }, capabilities: { shardTestFiles: true, maxInstances: 4, browserName: 'chrome', }, onCleanUp: function (results) { retry.onCleanUp(results); }, onPrepare: function () { retry.onPrepare(); require('jasmine-expect'); browser.ignoreSynchronization = true; }, afterLaunch: function() { return retry.afterLaunch(2); // number of retries ( default is 2 ) } };

dreuxl commented 5 years ago

Hi @Navneetsoni860

Do u have logs / traces of your issue?

Navneetsoni860 commented 5 years ago

It is not showing any error....If any of the spec failed then It's runing all specs 2 time.I want to rerun only failed specs .

dreuxl commented 5 years ago

please try to run your command line with DEBUG=* to get more logs on your side. without logs, debugging is hard.

kabomi commented 5 years ago

If, as suggested on Readme, use retry.onCleanUp(results);

Then later on files will be undefined on this line

function onCleanUp(results,files) {
    if (results) {
        writeToFile(files);
    }
}

Which will provoke to run all the specs again

It is related to this PR

So, what is missing is: Example code on onCleanUp about passing the failed spec file paths to retry.onCleanUp(results, files);

kabomi commented 5 years ago

@dreuxl I've debugged until the method onCleanUp is being called and some tests already failed. We are missing the list of files that failed on the method onCleanUp Let me know if you need anything else or something is not clear. Thanks

aamirafridi97 commented 5 years ago
[
  'test/ui/e2e/specs/messagePage/*.js',
  'test/ui/e2e/specs/paymentPage/*.js',
]

I have these tests. Each folder has 1 file in it. I intentionally make the test fail under paymentPage. I reran the test under messagePage as well :|

We have over 50 tests but just to see the issue I used the above example. I have this under onCleanUp

onCleanUp(results) {
    retry.onCleanUp(results);
  },
ShashankGupta28 commented 4 years ago

@dreuxl : Let me eleborate issue,

exports.config = Object.assign({
  specs: [
    "**/spec1.e2e-spec.ts",
    "**/spec2.e2e-spec.ts",
  ],
  framework: "jasmine",
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 900000,
    print: function () { }
  },
  onPrepare() {
    retry.onPrepare();
  },
  onCleanUp: function (results, files) {
    retry.onCleanUp(results, files);
  },
  afterLaunch: function () {
    return retry.afterLaunch(3);
  }
}

In this config if there is any single test failure in spec1.e2e-spec.ts. then all test cases of spec1.e2e-spec.ts & spec2.e2e-spec.ts are executed in rerun on next retry which is the issue.

Neal910 commented 4 years ago

Hi guys, any luck on solving this one or workaround? I am having the same issue.

No matter how I twist the onPrepare, onCleanup and afterLaunch in config file, I always have the whole list of test cases written in a the file that will be re-ran by protractor-retry library. as following:
`<?xml version="1.0" encoding="UTF-8"?>

**/login.spec.js,**/patient.spec.js,/usr/local/lib/node_modules/protractor/built/frameworks/__protractor_internal_afterEach_setup_spec.js `
yuezk commented 4 years ago

Seems to be a known issue as described in README, https://github.com/yahoo/protractor-retry#known-caveat

ashishgoel88 commented 3 years ago

Will this issue get resolved?

yuezk commented 3 years ago

Will this issue get resolved?

@ashishgoel88 You could give it a try on https://github.com/yuezk/protractor-jasmine-retry if you are using Jasmine as the test framework. As I remember, it resolved this issue.