Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion TUnit.Engine/Building/Collectors/AotTestDataCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private Task<TestMetadata> CreateMetadataFromDynamicDiscoveryResult(DynamicDisco
TestName = testName,
TestClassType = result.TestClassType,
TestMethodName = methodInfo.Name,
Dependencies = result.Attributes.OfType<DependsOnAttribute>().Select(a => a.ToTestDependency()).ToArray(),
Dependencies = ExtractDependencies(result.Attributes),
DataSources = [], // Dynamic tests don't use data sources in the same way
ClassDataSources = [],
PropertyDataSources = [],
Expand All @@ -286,6 +286,21 @@ private Task<TestMetadata> CreateMetadataFromDynamicDiscoveryResult(DynamicDisco
});
}

private static TestDependency[] ExtractDependencies(List<Attribute> attributes)
{
List<TestDependency>? dependencies = null;

foreach (var attribute in attributes)
{
if (attribute is DependsOnAttribute dependsOn)
{
(dependencies ??= []).Add(dependsOn.ToTestDependency());
}
}

return dependencies?.ToArray() ?? [];
}

private static Attribute[] GetDynamicTestAttributes(DynamicDiscoveryResult result)
{
if (result.TestClassType == null)
Expand Down
17 changes: 16 additions & 1 deletion TUnit.Engine/Discovery/ReflectionTestDataCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2229,7 +2229,7 @@ private Task<TestMetadata> CreateMetadataFromDynamicDiscoveryResult(DynamicDisco
TestName = testName,
TestClassType = result.TestClassType,
TestMethodName = methodInfo.Name,
Dependencies = result.Attributes.OfType<DependsOnAttribute>().Select(static a => a.ToTestDependency()).ToArray(),
Dependencies = ExtractDependencies(result.Attributes),
DataSources = [], // Dynamic tests don't use data sources in the same way
ClassDataSources = [],
PropertyDataSources = [],
Expand All @@ -2248,6 +2248,21 @@ private Task<TestMetadata> CreateMetadataFromDynamicDiscoveryResult(DynamicDisco
return Task.FromResult<TestMetadata>(metadata);
}

private static TestDependency[] ExtractDependencies(List<Attribute> attributes)
{
List<TestDependency>? dependencies = null;

foreach (var attribute in attributes)
{
if (attribute is DependsOnAttribute dependsOn)
{
(dependencies ??= []).Add(dependsOn.ToTestDependency());
}
}

return dependencies?.ToArray() ?? [];
}

private static Attribute[] GetDynamicTestAttributes(DynamicDiscoveryResult result)
{
if (result.TestClassType == null)
Expand Down
Loading