cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.07k stars 1.09k forks source link

Support soft assertions #2358

Closed user753 closed 11 months ago

user753 commented 11 months ago

I would like to fail some step but continue to run scenario after that. Is there any way to do it?

davidjgoss commented 11 months ago

Most JavaScript assertion libraries don't have a soft assert concept. But you could implement something in Cucumber, where you:

Relevant docs:

Happy to discuss more in #help-cucumber-js in the Slack, but going to close the issue as there's nothing for us to change here.

user753 commented 11 months ago

Thanks.

Most JavaScript assertion libraries don't have a soft assert concept. But you could implement something in Cucumber, where you:

Would it be possible to add soft to StepOptions?

export interface IDefineStepOptions {
    timeout?: number;
    soft?: boolean
    wrapperOptions?: any;
}
Then({soft: true}, ...)

In an After hook, check your World for any assertion errors, and if there are > 0 then throw from there to fail the scenario

Yes, I do something like that, but I would like to show this step as failed in report. Is it possible?

davidjgoss commented 11 months ago

This is not currently possible, no. Assertions are not in scope of what Cucumber does as purely a runner.

user753 commented 11 months ago

Assertions are not in scope of what Cucumber does as purely a runner.

But it's not about assertions, it's about running the test. I want to continue running the scenario even if some steps fail. There is already a similar feature for when there is no implementation for a step. Instead of stopping after the first missing step, it continues running to collect all missing steps. My case is exactly the same, but the problem isn't a missing step implementation, it's something else.