-
-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Problem
When a test method has a single parameter with a data source attribute, [CombinedDataSources] is still required:
[Test]
[CombinedDataSources] // seems redundant for a single parameter
public async Task Unauthenticated_Requests_Are_Rejected(
[ClassDataSource<ApiClientFixture>(Shared = SharedType.PerTestSession)]
ApiClientFixture client)
{
var response = await client.Client.GetAsync("/api/orders/mine");
await Assert.That(response.StatusCode).IsEqualTo(HttpStatusCode.Unauthorized);
}Without it, you get TUnit0070 and TUnit0038 errors.
Proposed Behavior
When a method has exactly one parameter with a data source attribute, TUnit could automatically treat it as a combined data source (there's nothing to combine - it's just a single source). The [CombinedDataSources] attribute would only be strictly required when there are 2+ parameters with data source attributes.
Alternatively, this could be its own attribute concept - something like parameter-level [ClassDataSource] being allowed without [CombinedDataSources] when there's only one parameter.
Context
Discovered while building the CloudShop Aspire + TUnit example (#4761). The AuthorizationTests class had a simple single-parameter test that required the extra attribute.