Selaa lähdekoodia

fix(test): unblock dotnet test discovery and exception assertion

Two latent issues exposed by running the xunit suite:

1. Microsoft.NET.Test.Sdk 18.3.0 defaults to Microsoft.Testing.Platform
   mode, which expects a MTP-compatible test runner. Furion.Xunit pulls
   xunit v2 (no MTP runner) and xunit.v3.assert was assertion-only, so
   no runner was registered with vstest — discovery returned zero
   tests. Adding xunit.runner.visualstudio 3.0.2 restores the v2 vstest
   adapter path that Furion.Xunit's TestFramework actually uses.

2. S8TimeoutEvaluatorTests.TimeoutParams_Throws_OnInvalidJson asserted
   Throws<JsonException> but System.Text.Json throws JsonReaderException
   (a subclass). xunit v3 Assert.Throws<T> is strict-typed; switching to
   ThrowsAny<T> restores the test author's original intent (any
   JsonException family exception).

Verified: dotnet test on net8.0 — 54 / 54 passed, including the new
S8ActiveFlowWatchServiceTests (5 cases for N-2 payload parser).
YY968XX 3 kuukautta sitten
vanhempi
commit
21f3be09a8

+ 1 - 0
server/Admin.NET.Test/Admin.NET.Test.csproj

@@ -17,6 +17,7 @@
     <PackageReference Include="Selenium.Support" Version="4.41.0" />
     <PackageReference Include="Selenium.WebDriver" Version="4.41.0" />
     <PackageReference Include="Selenium.WebDriver.MSEdgeDriver" Version="145.0.3800.82" />
+    <PackageReference Include="xunit.runner.visualstudio" Version="3.0.2" />
     <PackageReference Include="xunit.v3.assert" Version="3.2.2" />
   </ItemGroup>
 

+ 3 - 1
server/Admin.NET.Test/S8/S8TimeoutEvaluatorTests.cs

@@ -60,7 +60,9 @@ public class S8TimeoutEvaluatorTests
     public void TimeoutParams_Throws_OnInvalidJson()
     {
         // evaluator 在 EvaluateAsync 内 try/catch 该异常并降级为空命中;本断言锁定异常类型契约。
-        Assert.Throws<JsonException>(() => S8TimeoutParams.Parse("not-a-json"));
+        // ThrowsAny 而非 Throws:System.Text.Json 实际抛 JsonReaderException(JsonException 子类),
+        // xunit v3 的 Assert.Throws<T> 是 strict 类型匹配,必须用 ThrowsAny 接受子类。
+        Assert.ThrowsAny<JsonException>(() => S8TimeoutParams.Parse("not-a-json"));
     }
 
     [Fact]