Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same failed spec being marked to run twice with cucumber #111

Open
Phonesis opened this issue Apr 11, 2019 · 3 comments
Open

Same failed spec being marked to run twice with cucumber #111

Phonesis opened this issue Apr 11, 2019 · 3 comments

Comments

@Phonesis
Copy link

Seeing an issue with using protractor-flakes with Cucumber. When a spec fails (which for cucumber means a feature file) it is being re-run twice. This is the hook we use for logging failed specs:

After(async function (testCase) {
  if (testCase.result.status === Status.FAILED) {
    // Log the spec to the console for protractor-flake to be able to rerun the failed specs
    console.log('Specs:', testCase.sourceLocation.uri);
  }
  return Promise.resolve();
});

In Jenkins, I can see the spec being correctly logged and picked up when it tries to re-run the failing specs. However, somehow the same spec / feature file is being listed twice and therefore re-run twice:

Using cucumber to parse output
Re-running tests: test attempt 2
Re-running the following test files:
/var/lib/jenkins/jobs/workplace-frontend-K8s/jobs/workplace-ci-feature/branches/IncreasingBrowserStackTests/workspace/cucumber/features/retirementage.feature
cucumber/features/retirementage.feature

I am not sure what is up with this but tried completely disabing our hook for logging failed specs. When it is disabled the re-run still gets triggered because any failing spec is somehow still being detected. Any idea why?

We are running it with Protractor/Cucumber and against Chrome and Firefox drivers in parallel (not sure if a factor).

@NickTomlin
Copy link
Owner

Apologies for the late reply. It looks like the parser is picking up two files:

# one
/var/lib/jenkins/jobs/workplace-frontend-K8s/jobs/workplace-ci-feature/branches/IncreasingBrowserStackTests/workspace/cucumber/features/retirementage.feature
# two
cucumber/features/retirementage.feature

Without seeing more of the logs and your setup it's hard to know but my bet would be that either there's another thing logging out the failed spec or something is changing the path in the After hook you have.

@Phonesis
Copy link
Author

Phonesis commented May 1, 2019

Thanks for your reply. We are also seeing an issue where if a single Scenario fails in a Feature containing multiple Scenarios, the who Feature is re run? Is there any way we can set it to only run the failing Scenario(s) and not the entire Feature again?

@iegor-zabielin
Copy link

iegor-zabielin commented Mar 13, 2020

We faced the same issue, but with a shorter path:

# one
/e2e/dist/features/exampl1.feature
# two
dist/features/exampl1.feature

and as a workaround, we modified logging by adding the rest necessary path part before:
console.log('Specs:', `e2e/${testCase.sourceLocation.uri}`)

As a result, feature is logged only once:
/e2e/dist/features/exampl1.feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants