Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 5 additions & 6 deletions TUnit.Engine/Discovery/ReflectionTestDataCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private static async IAsyncEnumerable<TestMetadata> DiscoverTestsInAssemblyStrea
continue;
}

MethodInfo[] testMethods;
IEnumerable<MethodInfo> testMethods;
try
{
// Check if this class inherits tests from base classes
Expand All @@ -513,15 +513,14 @@ private static async IAsyncEnumerable<TestMetadata> DiscoverTestsInAssemblyStrea
{
// Get all test methods including inherited ones
testMethods = GetAllTestMethods(type)
.Where(static m => m.IsDefined(typeof(TestAttribute), inherit: false) && !m.IsAbstract)
.ToArray();
.Where(static m => m.IsDefined(typeof(TestAttribute), inherit: false) && !m.IsAbstract);
}
else
{
// Only get declared test methods
testMethods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly)
.Where(static m => m.IsDefined(typeof(TestAttribute), inherit: false) && !m.IsAbstract)
.ToArray();
testMethods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static |
BindingFlags.DeclaredOnly)
.Where(static m => m.IsDefined(typeof(TestAttribute), inherit: false) && !m.IsAbstract);
}
}
catch (Exception)
Expand Down
23 changes: 3 additions & 20 deletions TUnit.Engine/Services/TestRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ private async Task<TestMetadata> CreateMetadataFromDynamicDiscoveryResult(Dynami
TestName = testName,
TestClassType = result.TestClassType,
TestMethodName = methodInfo.Name,
Dependencies = GetDependenciesOptimized(result.Attributes),
Dependencies = result.Attributes.OfType<DependsOnAttribute>()
.Select(x => x.ToTestDependency())
.ToArray(),
DataSources = [],
ClassDataSources = [],
PropertyDataSources = [],
Expand Down Expand Up @@ -339,25 +341,6 @@ private sealed class PendingDynamicTest
public required Type TestClassType { get; init; }
}


/// <summary>
/// Optimized method to get dependencies without LINQ allocations
/// </summary>
private static TestDependency[] GetDependenciesOptimized(ICollection<Attribute> attributes)
{
var dependencies = new List<TestDependency>(attributes.Count);
foreach (var attr in attributes)
{
if (attr is DependsOnAttribute dependsOn)
{
dependencies.Add(dependsOn.ToTestDependency());
}
}
return dependencies.ToArray();
}



/// <summary>
/// Optimized method to convert attributes to array without LINQ allocations
/// </summary>
Expand Down
Loading