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

Add soft assert support #227

Open
mgrybyk opened this issue Oct 5, 2020 · 18 comments
Open

Add soft assert support #227

mgrybyk opened this issue Oct 5, 2020 · 18 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mgrybyk
Copy link
Member

mgrybyk commented Oct 5, 2020

No description provided.

@mgrybyk mgrybyk added the enhancement New feature or request label Oct 5, 2020
@christian-bromann
Copy link
Member

What does soft assert support mean?

@mgrybyk
Copy link
Member Author

mgrybyk commented Oct 5, 2020

A way to do multiple assertions within test then throw all the failed assertions in when the test ends.
By test I mean, for example, it block for mocha.

I'll add proper description of course, but a bit later

@alfonso-presa
Copy link
Member

alfonso-presa commented Nov 6, 2020

@mgrybyk, I just made this https://github.com/alfonso-presa/soft-assert (because we need something similar for long and expensive cucumber tests) and I though it might cover your needs. It's assertion and test-harness library agnostic, so it might fit well. A little bit more verbose than having it built in the assertion library though. Sorry for the advertising....

edit: Also the focus of this issue if I understood correctly is for assertion failure to be kept until the end of the test unit, which in common frameworks is the it block, but in case of cucumber is the step. We needed to retain the failures along the whole scenario until the end. I don't see how that could be done only by the assertion library without it being coupled to the testing frameworking.... That's why I created the library as an standalone tool....

@darkartswizard
Copy link

darkartswizard commented Feb 20, 2022

Adding another request for a SoftAssert feature in webdriverio-expect.

What a soft assert does is let the test continue even when the assertion fails.

This way you get a very telling metric: How many assertions passed and how many failed. Not that 1 of 10 tests failed - which seems insignificant - while hiding the fact that the next 30 assertions in that test failed as well - which seems rather significant.

Likewise if 1 assertion fails and 30 passed, it's likely going to be quick work to resolve.

@christian-bromann christian-bromann added the help wanted Extra attention is needed label Feb 22, 2022
@christian-bromann
Copy link
Member

Given expect-webdriverio enhances the expect package with wdio related matchers it seems to me that if expect supports soft assertion this package would support it too. Maybe worth raising an issue there?

@darkartswizard
Copy link

Fair enough.

@circa1741
Copy link

NUnit has Multiple Asserts. See https://docs.nunit.org/articles/nunit/writing-tests/assertions/multiple-asserts.html.

It would be nice if Webdrive.IO has the same capability.

"This is particularly useful for testing things like object initialization and UI appearance as well as certain kinds of integration testing."

@christian-bromann
Copy link
Member

@circa1741 I think we all agreed that soft assertions would be a nice option. Please get involved and help make it reality 😉

@DivyangRaval
Copy link

Hi All,

It is been 2 years since this request was raised.
This is very basic functionality as it() block represents a Test and one Test will have multiple Test Steps which need to be asserted if any step fails we should continue to the next step to make sure get the complete execution result of all steps.

Is there any specific reason why this request never gets prioritized?
Or we already have some feature/solution for this?

@christian-bromann
Copy link
Member

@DivyangRaval as I mentioned already in my previous posts: get involved and help us implement this feature.

@PipulPant
Copy link

Any update on soft assertion or alternative approach to achieve this?

@christian-bromann
Copy link
Member

@PipulPant did you read the thread here?

@darkartswizard
Copy link

Big fan of multiple validation.

@christian-bromann
Copy link
Member

It seems like there is some discussion going on in the expect package, see jestjs/jest#13205.

@anandmdas
Copy link

Adding this post on the same for developers webdriverio-community/wdio-cucumberjs-json-reporter#255

@christian-bromann
Copy link
Member

Inspiration for a possible implementation can be found in vitest-dev/vitest#3509

@pavankumardmg
Copy link

@christian-bromann
Copy link
Member

@pavankumardmg interesting, it seems like vitest did the same and created an expect.soft. This makes it easier for us to do the same without being dependent on expect. Any contributions are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

9 participants