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

allure-cucumberjs: report skipped scenarios in case of before hook failure #907

Closed
baev opened this issue Mar 12, 2024 · 2 comments
Closed
Labels
theme:cucumberjs CucumberJS related issue

Comments

@baev
Copy link
Member

baev commented Mar 12, 2024

Discussed in https://github.com/orgs/allure-framework/discussions/2410

Originally posted by devrajshetake March 11, 2024
I am using Cucumber and Playwright with typescript to run my BDD tests. The allure report I am generating contains all the executed scenarios, but it does not contain the scenarios which are not executed. A BeforeAll hook runs before execution of all the scenarios within a tag, the problem arises when the BeforeAll hook fails for some reason, all the scenarios within this tag wont be executed, so they wont be mention in the report. Due to this, the total number of scenarios within my test suit are being displayed less in the report. I want the unexecuted scenarios to be mentioned in the allure report. Is there a way to do so? Please help.

@baev baev added the theme:cucumberjs CucumberJS related issue label Jun 27, 2024
@baev
Copy link
Member Author

baev commented Jun 27, 2024

@devrajshetake Currently, exceptions in BeforeAll aren't handled properly by cucumberjs

Error: Unexpected error on worker.receiveMessage
    at exit (node_modules/@cucumber/cucumber/lib/runtime/parallel/run_worker.js:11:27)
    at node_modules/@cucumber/cucumber/lib/runtime/parallel/run_worker.js:24:31 {
  [cause]: Error: a BeforeAll hook errored on worker 2, process exiting: features/support/beforeAllFailure.js:3
      at Worker.runTestRunHooks (@cucumber-cucumber-npm-10.8.0-3268c4cd89-537bd8b891.zip/node_modules/@cucumber/cucumber/lib/runtime/run_test_run_hooks.js:24:23)
      at async Worker.initialize (@cucumber-cucumber-npm-10.8.0-3268c4cd89-537bd8b891.zip/node_modules/@cucumber/cucumber/lib/runtime/parallel/worker.js:53:9)
      at async Worker.receiveMessage (@cucumber-cucumber-npm-10.8.0-3268c4cd89-537bd8b891.zip/node_modules/@cucumber/cucumber/lib/runtime/parallel/worker.js:62:13) {
    [cause]: Error: before all error

So, Allure can't do much about it. Feel free to open a bug report/feature request for cucumber: https://github.com/cucumber/cucumber-js

@baev baev closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
@baev
Copy link
Member Author

baev commented Jun 27, 2024

I would suggest you avoid throwing exceptions in BeforeAll hooks, instead, you can use world parameters to pass the error to before hook and throw an exception in there:

BeforeAll(function () {
  try {
    doSomethingWithPossibleException();
  } catch (e) {
     this.parameters.error = e;
  }
});

Before(function () {
  if (this.parameters.error) {
    throw this.parameters.error;
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:cucumberjs CucumberJS related issue
Projects
None yet
Development

No branches or pull requests

1 participant