Skip to content

Assert.ThatAsync doesn't work correctly if calling nested Asserts #4919

@manfred-brands

Description

@manfred-brands

When working on #4909 I had a test like:

await Assert.ThatAsync(FailingDelayedAssertion, Throws.InstanceOf<AssertionException>()
    .With.Message.Contain("milliseconds delay")
    .With.Message.Contain("property ExpectedType.My:"));

Where FailingDelayedAssertion was a method calling Assert.ThatAsync and is throwing an AssertionException.
The above test is reports as failed, but no stack trace and no actual failure message relating to the above constraints.

If I change the text in the Contain causing the assert to fail, it then reports Multiple failures.
The failure in the original called Assert and the failure in the top-level Assert.

When changing this to the "pseudo-synchronous" version of Assert, the test passes.

Assert.That(FailingDelayedAssertion, Throws.InstanceOf<AssertionException>()
    .With.Message.Contain("milliseconds delay")
    .With.Message.Contain("property ExpectedType.My:"));

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions