Skip to content
Merged
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
Next Next commit
fix: resolve race condition in HookExecutionOrderTests
The BeforeEvery(Test) hook in GlobalHookExecutionOrderSetup fires for
every test in the assembly. When tests run concurrently, another test's
BeforeEvery invocation calls Clear() on the shared list between the
Before hook and the test body, causing the test to see count=2 instead
of 3.

Filter the BeforeEvery hook to only act on HookExecutionOrderTests.
  • Loading branch information
thomhurst committed Apr 3, 2026
commit d678a3e40bb3e3b7ddc47f2cac9dc505a193289d
7 changes: 6 additions & 1 deletion TUnit.Engine.Tests/HookExecutionOrderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ public sealed class GlobalHookExecutionOrderSetup
[BeforeEvery(Test)]
public static void GlobalSetup(TestContext context)
{
HookExecutionOrderTests._executionOrder.Clear(); // Clear before each test
if (context.Metadata.TestDetails.ClassType != typeof(HookExecutionOrderTests))
{
return;
}

HookExecutionOrderTests._executionOrder.Clear();
HookExecutionOrderTests._executionOrder.Add("BeforeEvery");
}
}
Expand Down
Loading