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

Accumulate further failures if any on AssertMultiple instead of throwing #4313

Merged

Conversation

ghost
Copy link

@ghost ghost commented Mar 16, 2023

Closes #4264

This implements the suggested solution. It turns out it was suitable to fix this issue. We still throw on the first fail, but any further one is only cumulated in case one appears after a catch block or in the teardown.

@mr-russ
Copy link
Contributor

mr-russ commented Mar 17, 2023

Is there a way to add a test to verify it will stay working in the future?
Should this get a 3.13-dev fix if it's accepted?

@ghost
Copy link
Author

ghost commented Mar 17, 2023

Is there a way to add a test to verify it will stay working in the future? Should this get a 3.13-dev fix if it's accepted?

I'm actually not sure how you can reliably test this: you expect an assert to fail, but lines after to be executed. I don't think I am knowledgeable enough on setting up such a test because the best I could get on my hand was expecting a failure shaped in a certain way in the console, I just don't know how you make a test for this.

As for 3.13, either works, it's a low priority issue.

@mr-russ
Copy link
Contributor

mr-russ commented Mar 22, 2023

I looked at how the existing AssertMultiple does its testing, and https://github.com/nunit/nunit/blob/master/src/NUnitFramework/tests/Assertions/AssertMultipleTests.cs#L124 suggests that making an explicit test that produces what you are expecting is probably the best method. Even if only run manually for checking it's reproducible and in the code and can be checked at any time.

@ghost ghost force-pushed the assertMultiple-cumulate-failures branch from 653b9ff to 94c5e65 Compare March 22, 2023 15:05
@ghost
Copy link
Author

ghost commented Mar 22, 2023

There, I added an explicit test

Copy link
Member

@stevenaw stevenaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix you applied here @sdelarosbil . The fix itself looks good, but can we add this repro as a non-explicit test so that it may fail if a future PR accidentally undoes your bugfix?

@OsirisTerje
Copy link
Member

@sdelarosbil Can you copy-add in the test that @stevenaw suggested? We could then merge this PR immediately after that. Nothing else seems to be missing in this PR.

@ghost
Copy link
Author

ghost commented Apr 3, 2023

@sdelarosbil Can you copy-add in the test that @stevenaw suggested? We could then merge this PR immediately after that. Nothing else seems to be missing in this PR.

Yes, I tried to add the test, the problem is it's not possible as far as I could see to make it not fail.

The test is designed to fail in a specific way such that something after an assert still executes. If I copy verbatim, the test fail, but in an expected way which I didn't find a way to turn it into a success. If there's something I am missing, please let me know, but I am confused how the test should be implemented to not have that happen.

@OsirisTerje OsirisTerje merged commit 1ae42fe into nunit:master Apr 6, 2023
5 checks passed
@OsirisTerje
Copy link
Member

@sdelarosbil Accepted, we'll move the testing out as a separate issue. @stevenaw or I can try to get it working.
The issue is #4331

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

Successfully merging this pull request may close these issues.

Assert.Multiple method should fail only if a contained assertion failed
4 participants