ANcpLua.NET.Sdk.Test) provides xUnit v3 with Microsoft Testing Platform and injects base classes for integration testing.
Microsoft Testing Platform (MTP)
The SDK uses xUnit v3 with Microsoft Testing Platform instead of VSTest.Auto-Configuration
MTP requires test projects to output executables. The SDK handles this automatically when you referencexunit.v3.mtp-v2:
CLI Syntax
MTP uses different command syntax than VSTest:.NET 10 includes native MTP support via
global.json. The -- separator is
only needed for .NET 8/9 with explicit MTP opt-in.Troubleshooting
xUnit v3 TestContext
xUnit v3 replaces constructor-injectedITestOutputHelper with ambient TestContext. Access test output anywhere without passing it through constructor chains.
Before vs After
Migration Example
IntegrationTestBase
In-memory TestServer for fast API testing.WebApplicationFactory<TProgram> internally.
KestrelTestBase
Real Kestrel server for HTTP/2, WebSockets, SSE, or Playwright.UseKestrel(0).
FakeLogger
See Extensions forFakeLogCollector test helpers.
AOT/Trim Testing
The SDK provides infrastructure for testing Native AOT and trimmed applications. Tests run as separate processes withPublishAot=true or PublishTrimmed=true to verify runtime behavior.
Enabling AOT Testing
ANcpLua.AotTesting.Attributes.
Writing AOT Tests
AOT tests are methods returningint with exit code 100 for success:
Test Attributes
[AotTest]
[AotTest]
Publishes with
PublishAot=true and executes the native binary.[TrimTest]
[TrimTest]
Publishes with
PublishTrimmed=true for testing IL trimming.TrimAssert Helpers
Verify types are trimmed or preserved at runtime:Feature Switches
Disable runtime features during tests:How It Works
- Discovery: MSBuild target scans for
[AotTest]/[TrimTest]methods - Project Generation: Creates temporary
.csprojfor each test - Publish: Runs
dotnet publishwith AOT/Trim flags - Execute: Runs the published executable
- Validate: Checks exit code (100 = success)
