diff --git a/docs/code-of-conduct/TESTING_PRACTICES.md b/docs/code-of-conduct/TESTING_PRACTICES.md index 127666437..638fcbe09 100644 --- a/docs/code-of-conduct/TESTING_PRACTICES.md +++ b/docs/code-of-conduct/TESTING_PRACTICES.md @@ -28,6 +28,14 @@ - Avoid live network calls; rely on fixtures and local emulators only. - Inject time and ID providers (TimeProvider, IGuidGenerator) for testability. +## Targeted xUnit v3 execution + +- Some Stella Ops test projects expose the xUnit v3 in-process runner through Microsoft Testing Platform. +- On those projects, `dotnet test --filter ...` may be ignored even when the caller expects a narrow subset. +- For targeted verification on those projects, use `pwsh ./scripts/test-targeted-xunit.ps1 -Project .csproj ...` or execute the produced test DLL directly with `dotnet exec`. +- Capture the exact targeted method/class/trait arguments in sprint evidence so reviewers can confirm the run was actually scoped. +- If the test assembly is stale, rebuild the specific `.csproj` first; prefer a scoped build over a solution-wide rebuild. + --- ## Intent tagging (Turn #6) diff --git a/docs/qa/feature-checks/FLOW.md b/docs/qa/feature-checks/FLOW.md index 0a6054f47..fa6a8defe 100644 --- a/docs/qa/feature-checks/FLOW.md +++ b/docs/qa/feature-checks/FLOW.md @@ -176,7 +176,9 @@ the described behavior. **Process**: 1. Identify the `.csproj` file(s) for the feature's module 2. Run `dotnet build .csproj` and capture output -3. Run `dotnet test .csproj --filter ` -- tests MUST actually execute and pass +3. Run the targeted tests and confirm the filter actually executes the intended subset. + - For VSTest-style projects where filtering works normally, use `dotnet test .csproj --filter `. + - For xUnit v3 projects running under Microsoft Testing Platform, do **not** rely on `dotnet test --filter`; use `scripts/test-targeted-xunit.ps1` or direct `dotnet exec -method/-class/...` instead. 4. For Angular/frontend features: run `npx ng build` and `npx ng test` for the relevant library/app 5. **Code review** (CRITICAL): Read the key source files and verify: - The classes/methods described in the feature file actually contain the logic claimed @@ -364,13 +366,17 @@ integration tests** or **behavioral unit tests** that prove the feature logic: **Process**: 1. Identify tests that specifically exercise the feature's behavior -2. Run those tests: `dotnet test --filter "FullyQualifiedName~FeatureClassName"` +2. Run those tests using a targeting path that actually filters the assembly: + - VSTest-compatible path: `dotnet test .csproj --filter "FullyQualifiedName~FeatureClassName"` + - xUnit v3 / Microsoft Testing Platform path: `pwsh ./scripts/test-targeted-xunit.ps1 -Project .csproj -Class ""` 3. Read the test code to confirm it asserts meaningful behavior (not just "compiles") 4. If no behavioral tests exist, write a focused test and run it **Example for `evidence-weighted-score-model`**: ```bash -dotnet test --filter "FullyQualifiedName~EwsCalculatorTests" +pwsh ./scripts/test-targeted-xunit.ps1 \ + -Project src/Policy/__Tests/StellaOps.Policy.Engine.Tests/StellaOps.Policy.Engine.Tests.csproj \ + -Class "StellaOps.Policy.Engine.Tests.Scoring.EwsCalculatorTests" # Verify: normalizers produce expected dimension scores # Verify: guardrails cap/floor scores correctly # Verify: composite score is deterministic for same inputs @@ -381,7 +387,7 @@ dotnet test --filter "FullyQualifiedName~EwsCalculatorTests" { "type": "integration", "capturedAtUtc": "2026-02-10T12:00:00Z", - "testFilter": "FullyQualifiedName~EwsCalculatorTests", + "testFilter": "StellaOps.Policy.Engine.Tests.Scoring.EwsCalculatorTests", "testsRun": 21, "testsPassed": 21, "testsFailed": 0, diff --git a/scripts/test-targeted-xunit.ps1 b/scripts/test-targeted-xunit.ps1 index 250ab8d3e..ec15bf67c 100644 --- a/scripts/test-targeted-xunit.ps1 +++ b/scripts/test-targeted-xunit.ps1 @@ -131,7 +131,9 @@ function Resolve-Framework { param( [Parameter(Mandatory)] $Metadata, - [string]$RequestedFramework + [string]$RequestedFramework, + [Parameter(Mandatory)] + [string]$ProjectPath ) if ($RequestedFramework) { @@ -180,7 +182,7 @@ function Assert-FilterShape { $repoRoot = Resolve-RepoRoot $projectPath = Resolve-ProjectPath -InputPath $Project -RepoRoot $repoRoot $metadata = Get-ProjectMetadata -ProjectPath $projectPath -$resolvedFramework = Resolve-Framework -Metadata $metadata -RequestedFramework $Framework +$resolvedFramework = Resolve-Framework -Metadata $metadata -RequestedFramework $Framework -ProjectPath $projectPath Assert-FilterShape -MethodFilters $Method -ClassFilters $Class -NamespaceFilters $Namespace -TraitFilters $Trait -Query $QueryFilter