From 45f88d2d18facec2bee3420bdfb00532cec3d63f Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 19 Aug 2026 14:06:24 +0200 Subject: [PATCH] test: serialize Launcher.Tests via an assembly attribute, not xunit.runner.json MainWindowViewTests kept failing on CI in Test Case Cleanup ('The calling thread cannot access this object') while passing 56/56 locally. The cause was delivery, not the fix: xunit.runner.json only takes effect if it is copied beside the test DLL, and under CI's 'dotnet build' + 'dotnet test --no-build' split it did not arrive, so CI ran with parallel collections while local runs did not. [assembly: CollectionBehavior(DisableTestParallelization = true)] is compiled into the DLL and cannot fail to deploy. It lives beside the existing AvaloniaTestApplication/AvaloniaTestIsolation attributes, which document the same thread-affinity hazard. The json and its csproj copy rule are removed so there is one source of truth. --- .../AcDream.Launcher.Tests.csproj | 10 ---------- tests/AcDream.Launcher.Tests/TestAppBuilder.cs | 9 +++++++++ tests/AcDream.Launcher.Tests/xunit.runner.json | 6 ------ 3 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 tests/AcDream.Launcher.Tests/xunit.runner.json diff --git a/tests/AcDream.Launcher.Tests/AcDream.Launcher.Tests.csproj b/tests/AcDream.Launcher.Tests/AcDream.Launcher.Tests.csproj index 78b2ec1b..23aedde8 100644 --- a/tests/AcDream.Launcher.Tests/AcDream.Launcher.Tests.csproj +++ b/tests/AcDream.Launcher.Tests/AcDream.Launcher.Tests.csproj @@ -23,14 +23,4 @@ - - - - - diff --git a/tests/AcDream.Launcher.Tests/TestAppBuilder.cs b/tests/AcDream.Launcher.Tests/TestAppBuilder.cs index 4245f0e4..777f559b 100644 --- a/tests/AcDream.Launcher.Tests/TestAppBuilder.cs +++ b/tests/AcDream.Launcher.Tests/TestAppBuilder.cs @@ -1,9 +1,18 @@ using Avalonia; using Avalonia.Headless; +using Xunit; [assembly: AvaloniaTestApplication(typeof(AcDream.Launcher.Tests.TestAppBuilder))] [assembly: AvaloniaTestIsolation(AvaloniaTestIsolationLevel.PerAssembly)] +// Compiled INTO the assembly on purpose. A xunit.runner.json expresses the same +// intent but only works if the file is copied beside the test DLL; under CI's +// `dotnet build` + `dotnet test --no-build` split it did not arrive, so the +// suite ran with parallel collections and MainWindowViewTests failed in Test +// Case Cleanup ("The calling thread cannot access this object") while passing +// locally. An assembly attribute cannot fail to deploy. +[assembly: CollectionBehavior(DisableTestParallelization = true)] + namespace AcDream.Launcher.Tests; /// diff --git a/tests/AcDream.Launcher.Tests/xunit.runner.json b/tests/AcDream.Launcher.Tests/xunit.runner.json deleted file mode 100644 index c3155894..00000000 --- a/tests/AcDream.Launcher.Tests/xunit.runner.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", - "parallelizeAssembly": false, - "parallelizeTestCollections": false, - "maxParallelThreads": 1 -}