From 1c958654505a38fbba8ccc978b4c913db8e20951 Mon Sep 17 00:00:00 2001 From: laurentiu021 Date: Mon, 18 May 2026 11:38:07 +0300 Subject: [PATCH] test: enable parallelism, add NSubstitute, document test infrastructure (TEST-M4, H1) --- CHANGELOG.md | 13 +++++++++ .../SysManager.Tests/SysManager.Tests.csproj | 1 + SysManager/SysManager.Tests/xunit.runner.json | 6 ++--- TESTING.md | 27 +++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb089bc..35158908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [0.48.31] - 2026-05-18 + +### Changed +- **Test parallelism** — enabled `parallelizeTestCollections` in xunit.runner.json + so pure-logic unit tests run concurrently, reducing CI test time. Tests that + touch shared OS resources remain serialized via `[Collection("Network")]` + (TEST-M4). +- **Mocking framework** — added NSubstitute 5.3 to the test project, enabling + interface-based mocking for future tests that need to isolate OS dependencies + (TEST-H1). +- **TESTING.md** — documented test infrastructure (frameworks, parallelism + strategy, conventions for mocking and time-dependent tests). + ## [0.48.30] - 2026-05-18 ### Fixed diff --git a/SysManager/SysManager.Tests/SysManager.Tests.csproj b/SysManager/SysManager.Tests/SysManager.Tests.csproj index 9bbf9be1..01c87013 100644 --- a/SysManager/SysManager.Tests/SysManager.Tests.csproj +++ b/SysManager/SysManager.Tests/SysManager.Tests.csproj @@ -13,6 +13,7 @@ + diff --git a/SysManager/SysManager.Tests/xunit.runner.json b/SysManager/SysManager.Tests/xunit.runner.json index 32091f95..4504ac91 100644 --- a/SysManager/SysManager.Tests/xunit.runner.json +++ b/SysManager/SysManager.Tests/xunit.runner.json @@ -1,6 +1,6 @@ { "parallelizeAssembly": false, - "parallelizeTestCollections": false, - "maxParallelThreads": 1, - "longRunningTestSeconds": 120 + "parallelizeTestCollections": true, + "maxParallelThreads": 0, + "longRunningTestSeconds": 30 } diff --git a/TESTING.md b/TESTING.md index 882fdb2e..7b846f92 100644 --- a/TESTING.md +++ b/TESTING.md @@ -49,6 +49,33 @@ Coverage is collected automatically on CI via `coverlet` and uploaded to [Codecov](https://codecov.io/gh/laurentiu021/SystemManager). The badge in `README.md` reflects the latest `main` branch result. +## Test infrastructure + +### Frameworks + +| Package | Purpose | +|---|---| +| xUnit 2.9 | Test framework | +| NSubstitute 5.3 | Mocking/substitution for interface-based testing | +| coverlet | Code coverage collection | +| Xunit.StaFact | STA thread support for WPF-dependent tests | + +### Parallelism + +Unit tests run in parallel by default (`parallelizeTestCollections: true`). +Tests that share state or touch OS resources are isolated via xUnit +collection definitions: + +- `[Collection("Network")]` — tests using ICMP sockets run sequentially. + +### Conventions + +- Pure logic tests (parsers, analyzers, converters) need no mocking. +- Tests that depend on OS services should use NSubstitute to mock the + service interface, keeping the test fast and deterministic. +- Time-dependent tests should use injectable time sources or generous + tolerances to avoid flakiness on slow CI runners. + To generate a local coverage report: ```powershell