Skip to content

Include actual value in exception message of CollectionIsEmptyAssertion #3382

@PhilippNaused

Description

@PhilippNaused

When the IsEmpty() assertion fails, the error message doesn't say what elements were found. Only that the collection wasn't empty.

[Test]
public async Task Test1()
{
    List<int> a = [1, 2, 3];
    await Assert.That(a).IsEmpty();
}

Results in:

AssertionException: Expected to be empty
but collection contains items

It would be very helpful if the message contained the string representation of the elements.
Other assertion types (like IsEquivalentTo) return information about the mismatched elements, so I would expect IsEmpty to do the same.

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