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.
This commit is contained in:
parent
daf28bfec5
commit
45f88d2d18
3 changed files with 9 additions and 16 deletions
|
|
@ -23,14 +23,4 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\AcDream.Launcher\AcDream.Launcher.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- Avalonia's headless session is thread-affine, and its per-test cleanup
|
||||
runs on whichever thread xUnit hands it. Under the default parallel
|
||||
collections MainWindowViewTests failed in Test Case Cleanup with
|
||||
"The calling thread cannot access this object because a different
|
||||
thread owns it" while passing in isolation. Same serialization
|
||||
settings AcDream.Core.Tests already uses. -->
|
||||
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
|
||||
"parallelizeAssembly": false,
|
||||
"parallelizeTestCollections": false,
|
||||
"maxParallelThreads": 1
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue