Skip to content

[Bug]: TUnit0001 not reporting for TypedDataSourceAttribute #4740

@aomader

Description

@aomader

Description

I assumed that TUnit0001 would work with ITypedDataSource, and thus TypedDataSourceAttribute. However, the following, obviously wrong example, compiles just fine:

public class Playground
{
    [Test]
    [CustomData]
    public void Test(string asdf, int notExistingParameter)
    {
        Assert.Fail("foobar");
    }
}

[AttributeUsage(AttributeTargets.Method)]
public class CustomData : TypedDataSourceAttribute<string>
{
    public override async IAsyncEnumerable<Func<Task<string>>> GetTypedDataRowsAsync(
        DataGeneratorMetadata dataGeneratorMetadata
    )
    {
        await Task.Yield();
        yield return () => Task.FromResult("one");
    }
}

Expected Behavior

I expected that it would not compile and show an error, since the typed data source does not method the test method signature.

Actual Behavior

I expected that the TUnit0001 error is shown, as it is shown for a mismatching [Arguments] for example.

Steps to Reproduce

See the code above.

TUnit Version

1.13.40

.NET Version

.NET 10

Operating System

macOS

IDE / Test Runner

JetBrains Rider

Error Output / Stack Trace

Running it with `dotnet test`, the following error is shown:

TUnit.Engine.Exceptions.TestFailedException: ArgumentException: Expected exactly 2 arguments, but got 1

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

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions