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
7 changes: 2 additions & 5 deletions TUnit.Engine/Framework/TestRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,8 @@ private async Task HandleRunRequestAsync(

var allTests = discoveryResult.Tests.ToArray();

foreach (var test in allTests)
{
context.CancellationToken.ThrowIfCancellationRequested();
await serviceProvider.MessageBus.Discovered(test.Context);
}
// Skip sending Discovered messages during execution - they're only needed for discovery requests
// This saves significant time and allocations when running tests

await serviceProvider.TestSessionCoordinator.ExecuteTests(
allTests,
Expand Down
5 changes: 2 additions & 3 deletions TUnit.Engine/Interfaces/IDynamicTestQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ namespace TUnit.Engine.Interfaces;
internal interface IDynamicTestQueue
{
/// <summary>
/// Enqueues a test for execution and notifies the message bus. Thread-safe.
/// Enqueues a test for execution. Thread-safe.
/// </summary>
/// <param name="test">The test to enqueue</param>
/// <returns>Task that completes when the test is enqueued and discovery is notified</returns>
Task EnqueueAsync(AbstractExecutableTest test);
void Enqueue(AbstractExecutableTest test);

/// <summary>
/// Attempts to dequeue the next test. Thread-safe.
Expand Down
5 changes: 3 additions & 2 deletions TUnit.Engine/Services/DynamicTestQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public DynamicTestQueue(ITUnitMessageBus messageBus)
});
}

public async Task EnqueueAsync(AbstractExecutableTest test)
public void Enqueue(AbstractExecutableTest test)
{
Interlocked.Increment(ref _pendingCount);

Expand All @@ -39,7 +39,8 @@ public async Task EnqueueAsync(AbstractExecutableTest test)
throw new InvalidOperationException("Failed to enqueue test to dynamic test queue.");
}

await _messageBus.Discovered(test.Context);
// Skip sending Discovered message - dynamic tests are created during execution,
// and Discovered messages are only needed for discovery requests
}

public bool TryDequeue(out AbstractExecutableTest? test)
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Engine/Services/TestRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private async Task ProcessPendingDynamicTests()

foreach (var test in builtTests)
{
await _dynamicTestQueue.EnqueueAsync(test);
_dynamicTestQueue.Enqueue(test);
}
}

Expand Down
Loading