Skip to content

[Bug]: The migration from xUnit’s Assert.Throws is incorrect #5817

@kzrnm

Description

@kzrnm

Description

In the documentation of migration from xUnit, it looks like the following.
However, Assert.ThrowsAsync does not take an Action as an argument, so this results in a CS0029 compile-time error.

xunit

Assert.Throws<ArgumentException>(() => ThrowsException());

TUnit

await Assert.ThrowsAsync<ArgumentException>(() => ThrowsException());

https://tunit.dev/docs/migration/xunit/#exception-assertions

Expected Behavior

Provide an alternative that does not use Assert.ThrowsAsync.

  • documentation
  • CodeFix

Actual Behavior

using Assert.ThrowsAsync.

Steps to Reproduce

migration

TUnit Version

latest

.NET Version

any

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