Skip to content

[Bug]: xUnit code fixer drops Assert.Collection assertions #4806

@ascott18

Description

@ascott18

Description

An xunit assertion with item inspectors like this...

        Assert.Collection(orderings,
            ordering =>
            {
                var prop = Assert.Single(ordering.Properties);
                Assert.Equal("Parent", prop.Name);
            }
        );

... has the item inspectors dropped entirely, leaving only await Assert.That(orderings).HasCount(1);

This leads to tests that still pass, but in a large test refactor, its easy to miss that the other assertions were lost.

Expected Behavior

Item assertions are preserved in some form, or the Assert.Collection is left as-is for the user to convert to TUnit manually.

Actual Behavior

Assertions are dropped in a way that still leaves passing tests in place, but missing additional critical test logic.

Steps to Reproduce

Run xUnit code fixer on an assertion like this:

        Assert.Collection(orderings,
            ordering =>
            {
                var prop = Assert.Single(ordering.Properties);
                Assert.Equal("Parent", prop.Name);
            }
        );

TUnit Version

1.14.0

.NET Version

NET 10

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

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