Skip to content

[Bug]: Chaining .And produces unclear Failure messages #5573

@Hendrik-Rassmann

Description

@Hendrik-Rassmann

Description

Considering the example from the Documentation regarding Collections with a slight change:

    var numbers = new[] { 1, 2, 3, 4, 1 };

    // Assert count and then chain with other collection assertions
    await Assert.That(numbers)
        .Count().IsEqualTo(5)
        .And.Contains(3)
        .And.IsInOrder();

Produces a unclear Assertion Failure:
[Assertion Failure] Expected both conditions and to be in ascending order but item at index 4 (1) was less than previous item (4)

issues:

  • talks about "both" conditions, even though there are 3
  • doesn't mention the passing conditions (but it does so, if .And is chained only once)

Expected Behavior

[Assertion Failure] Expected 3 conditions
first condition
and second condition
and to be in ascending order
but item at index 4 (1) was less than previous item (4) violating condition 3

Actual Behavior

[Assertion Failure] Expected both conditions
and to be in ascending order
but item at index 4 (1) was less than previous item (4)

Steps to Reproduce

public async Task MultipleAndTest()
    {
        var numbers = new[] { 1, 2, 3, 4, 1 };

        // Assert count and then chain with other collection assertions
        await Assert.That(numbers)
            .Count().IsEqualTo(5)
            .And.Contains(3)
            .And.IsInOrder();
    }

TUnit Version

v1.34.5 (minor)

.NET Version

NET 10.0.103

Operating System

Linux

IDE / Test Runner

JetBrains Rider

Error Output / Stack Trace

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions