Skip to content

WithResult extension is always waiting for the Task to be completed #1969

@lg2de

Description

@lg2de

With #1478 I implemented the extension methods WithResult for assertions on asynchronous operations.
While playing around with this methods together with failed Should().CompleteWithinAsync I found that it could be unexpected, that these methods explicitly waiting for the completion of the Task.
The original intention of the assertions CompleteWithinAsync were ensuring tests will not hang forever. With awaiting the Task the "timeout" is skipped and the test may hang.

Today I think whether it would be better to not await the Task and instead check whether it is already completed.
In case the Task is not completed, further the result is not relevant anymore, isn't it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions