Description
It looks like regardless of the level at which TUnit.Core.Executors.Culture attribute is applied (assembly, class, or test), the Before(Test) and After(Test) setup hooks are still run in the default machine culture, and it's changed only for the test thread.
This makes culture-specific hooks unusable. Those setup / cleanup methods just have to be called from within the test itself.
Expected Behavior
Hooks at the level where [Culture] attribute is applied are executed in the specified culture:
Before(Test) / After(Test) hooks use test-level culture, if not specified - class-level culture, if not specified - assembly-level culture, if not specified - default culture.
Before(Class) / After(Class) hooks use class-level culture, if not specified - assembly-level culture, if not specified - default culture.
Before(Assembly) / After(Assembly) hooks use assembly-level culture, if not specified - default culture.
Actual Behavior
Hooks are run in the default culture and the culture is only changed for the actual test method.
Steps to Reproduce
[Culture("de-DE")]
public class MyTest
{
[Before(Test)]
public void SetUp()
{
Console.WriteLine($"Running setup in thread {Thread.CurrentThread.ManagedThreadId} in {Thread.CurrentThread.CurrentCulture.Name}");
}
[Test]
[Culture("fr-FR")]
public void MyTestMethod()
{
Console.WriteLine($"Running test in thread {Thread.CurrentThread.ManagedThreadId} in {Thread.CurrentThread.CurrentCulture.Name}");
}
[Test]
public void MyTestMethod2()
{
Console.WriteLine($"Running test 2 in thread {Thread.CurrentThread.ManagedThreadId} in {Thread.CurrentThread.CurrentCulture.Name}");
}
}
TUnit Version
1.29.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Running setup in thread 20 in en-US
Running test in thread 24 in fr-FR
Running setup in thread 3 in en-US
Running test 2 in thread 25 in de-DE
Additional Context
No response
IDE-Specific Issue?
Description
It looks like regardless of the level at which
TUnit.Core.Executors.Cultureattribute is applied (assembly, class, or test), theBefore(Test)andAfter(Test)setup hooks are still run in the default machine culture, and it's changed only for the test thread.This makes culture-specific hooks unusable. Those setup / cleanup methods just have to be called from within the test itself.
Expected Behavior
Hooks at the level where
[Culture]attribute is applied are executed in the specified culture:Before(Test)/After(Test)hooks use test-level culture, if not specified - class-level culture, if not specified - assembly-level culture, if not specified - default culture.Before(Class)/After(Class)hooks use class-level culture, if not specified - assembly-level culture, if not specified - default culture.Before(Assembly)/After(Assembly)hooks use assembly-level culture, if not specified - default culture.Actual Behavior
Hooks are run in the default culture and the culture is only changed for the actual test method.
Steps to Reproduce
TUnit Version
1.29.0
.NET Version
.NET 10
Operating System
Windows
IDE / Test Runner
dotnet CLI (dotnet test / dotnet run)
Error Output / Stack Trace
Additional Context
No response
IDE-Specific Issue?
dotnet testordotnet run, not just in my IDE