Skip to content

Assert.ThrowsAsync(Func<Task>) seems faulty #3521

@space-alien

Description

@space-alien

Assert.ThrowsAsync(Func<Task>) seems faulty:

static Task DoesNotThrow() => Task.CompletedTask;

[Test]
public async Task TUnit_Assert_ThrowsAsync()
{
    await DoesNotThrow(); // fine

    await Assert.ThrowsAsync(DoesNotThrow);                     // no exception, test passes!
    await Assert.ThrowsAsync(() => DoesNotThrow());             // no exception, test passes!
    await Assert.ThrowsAsync(async () => await DoesNotThrow()); // no exception, test passes!
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions