You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few situations where spurious AssertionResult entries are created in the result:
Assert.Throws or ThrowsConstraint when the code executed by the delegate argument includes asserts. The second-level asserts may leave failure and warning entries in the result that is being used for the top level test.
Executing code that causes an AssertionException and then catches it. This is done in some of our NUnit tests and it's a "trick" used by some users. The failure represented by the exception is added to the result before we can catch it.
Any Assert that takes a delegate could theoretically do the same thing if there were Asserts in the code executed. However, this is something of a pathological situation, since there isn't much reason to use Asserts in such delegates.
To resolve this, all such "second level" code should be executed in an isolated context and should apply to a separate result, which is ignored by the top-level code.
The text was updated successfully, but these errors were encountered:
To document the problem, here is a list of all TestFixtures with cases that produce spurious AssertionResult entries with a Status of "Failure" even though the test itself passes.
In each case the Assert.AreEqual expression fails, adding a failed AssertionResult to the test result. Even though the outer logic in each case causes the test to be marked as a success, the failed result remains and is written to the XML file.
To resolve this, both Assert.Throws and ThrowsConstraint need to be modified to run the provided delegate or lambda in an isolated TestExecutionContext, producing a result which is discarded.
Uh oh!
There was an error while loading. Please reload this page.
There are a few situations where spurious AssertionResult entries are created in the result:
Assert.Throws or ThrowsConstraint when the code executed by the delegate argument includes asserts. The second-level asserts may leave failure and warning entries in the result that is being used for the top level test.
Executing code that causes an AssertionException and then catches it. This is done in some of our NUnit tests and it's a "trick" used by some users. The failure represented by the exception is added to the result before we can catch it.
Any Assert that takes a delegate could theoretically do the same thing if there were Asserts in the code executed. However, this is something of a pathological situation, since there isn't much reason to use Asserts in such delegates.
To resolve this, all such "second level" code should be executed in an isolated context and should apply to a separate result, which is ignored by the top-level code.
The text was updated successfully, but these errors were encountered: