Skip to content

[Bug]: ArgumentsAttribute accepts only constant expressions #5186

Description

@Lexy2

Description

Well, I'm not sure if it's a bug or a feature request or kind of both.

I'm migrating from NUnit and there are a few tests that accept DateTime as a parameter. NUnit could handle this case by converting the passed string parameter into the respective DateTime, but TUnit seems to be stricter about parameter types.

As such, I can't use the following pattern:

[Test]
[Arguments("2022-5-31")]
[Arguments("2022-6-1")]
public void MyTest(DateTime testDate)
...

Is my only option here a MethodDataSource?

Expected Behavior

To be able to use struct types as arguments

Actual Behavior

TUnit0001: Attribute argument types 'string' don't match method parameter types 'System.DateTime'

Steps to Reproduce

See description

TUnit Version

1.19.74

.NET Version

.NET 10.0

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