From 1a5fad2d11260abac190891553f9dc93cd2cfc50 Mon Sep 17 00:00:00 2001 From: Agent Driver Date: Fri, 27 Nov 2026 16:14:03 -0500 Subject: [PATCH] Rename tests/DependencyModules.Tests to tests/DependencyModules.xUnit.Tests The project now holds only the tests of the xUnit and NUnit integrations, which need the xUnit runner. Drop the references and the shared harness link that its remaining tests no longer use, and describe the split of the test suites in CONTRIBUTING.md and CHANGELOG.md. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 +++ CONTRIBUTING.md | 22 ++++++++- DependencyModules.sln | 2 +- scripts/coverage.sh | 2 +- scripts/test-xunit.sh | 2 +- .../Infrastructure/Require.cs | 4 +- .../Infrastructure/Snapshot.cs | 4 +- .../DependencyModules.xUnit.Tests.csproj} | 45 ++++--------------- .../NUnitTests/ModuleTestAttributeTests.cs | 0 .../NUnitTests/NUnitDataSamples.cs | 0 .../TestingTests/TestContainerSourceTests.cs | 0 .../xUnitTests/AttributeUtilityTests.cs | 0 .../xUnitTests/ModuleTestCaseDataTests.cs | 0 .../xUnitTests/ModuleTestDiscovererTests.cs | 0 14 files changed, 42 insertions(+), 45 deletions(-) rename tests/{DependencyModules.Tests/DependencyModules.Tests.csproj => DependencyModules.xUnit.Tests/DependencyModules.xUnit.Tests.csproj} (57%) rename tests/{DependencyModules.Tests => DependencyModules.xUnit.Tests}/NUnitTests/ModuleTestAttributeTests.cs (100%) rename tests/{DependencyModules.Tests => DependencyModules.xUnit.Tests}/NUnitTests/NUnitDataSamples.cs (100%) rename tests/{DependencyModules.Tests => DependencyModules.xUnit.Tests}/TestingTests/TestContainerSourceTests.cs (100%) rename tests/{DependencyModules.Tests => DependencyModules.xUnit.Tests}/xUnitTests/AttributeUtilityTests.cs (100%) rename tests/{DependencyModules.Tests => DependencyModules.xUnit.Tests}/xUnitTests/ModuleTestCaseDataTests.cs (100%) rename tests/{DependencyModules.Tests => DependencyModules.xUnit.Tests}/xUnitTests/ModuleTestDiscovererTests.cs (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6cff56..a7ab6bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `DependencyModules.Testing` depends on `DependencyModules.Runtime` and on `Microsoft.Extensions.DependencyInjection`: version 8.0.1 for `net8.0` and version 10.0.0 for `net10.0`. Before, it depended on `Microsoft.Extensions.DependencyInjection.Abstractions` only. +- The unit tests are in two projects. `tests/DependencyModules.Specs` runs on VerificationGlue.Tests + and has the tests of the runtime, the source generator, the code fixes, the public API, and + `DependencyModules.Testing`. `scripts/test-verificationglue.sh` runs it. The tests of the xUnit + and NUnit integrations stay on xUnit, in `tests/DependencyModules.xUnit.Tests`, which was + `tests/DependencyModules.Tests`. `scripts/test-xunit.sh` runs them on each `xunit.v3` major. No + package changes. (#136, #137, #138, #139, #140) ## [1.7.0] - 2026-09-25 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f45d58a..376f954 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,27 @@ dotnet build DependencyModules.sln --configuration Release The `restore` step needs the `test-tools` feed in `NuGet.config`, which has the Microsoft.Testing.Platform 3 preview that VerificationGlue.Tests uses. No shipping package references VerificationGlue. -The unit tests are in two projects while they move to VerificationGlue.Tests. `tests/DependencyModules.Specs` has the `RuntimeTests`, `ApiTests` and `GeneratorTests` folders. `tests/DependencyModules.Tests` has the other folders. Both projects compile the test harness in `tests/DependencyModules.Specs/Infrastructure`. Each project reads the snapshots in its own `Snapshots` folder. +### The test suites + +| Project | Runner | Target frameworks | What it tests | +| --- | --- | --- | --- | +| `tests/DependencyModules.Specs` | VerificationGlue.Tests | `net10.0` | The runtime, the source generator, the code fixes, the public API, and DependencyModules.Testing | +| `tests/DependencyModules.xUnit.Tests` | xUnit | `net8.0`, `net10.0` | DependencyModules.xUnit, DependencyModules.xUnit4, and DependencyModules.NUnit | +| `integ-tests/SutProject.Tests` | xUnit | `net8.0`, `net10.0` | The generated code of a real project, through DependencyModules.xUnit | +| `integ-tests/web/WebApiApp.Tests` | xUnit | `net8.0`, `net10.0` | The generated code of an ASP.NET Core application, through DependencyModules.xUnit | +| `integ-tests/SutProject.NUnitTests` | NUnit | `net8.0`, `net10.0` | The generated code of a real project, through DependencyModules.NUnit | + +Put a new unit test in `tests/DependencyModules.Specs`. Its tests use `[VerifyTest]` and `Verify(...)`. When a check fails, the message shows the expression and the value of each part of it. The project has the test harness in `Infrastructure` and the snapshots in `Snapshots`. + +Put a test in `tests/DependencyModules.xUnit.Tests` only when it tests the xUnit or NUnit integration. These tests use `[ModuleTest]` from DependencyModules.xUnit, or they call the `xunit.v3` extensibility types directly. Thus they must run on xUnit, and they run on each `xunit.v3` major. The project also targets `net8.0`, because the integration packages have a `net8.0` build. + +To run `tests/DependencyModules.Specs`, use `./scripts/test-verificationglue.sh`. To run one of the other projects with `xunit.v3` version 3, use `dotnet test`: + +```shell +dotnet test tests/DependencyModules.xUnit.Tests --configuration Release +``` + +`./scripts/coverage.sh` runs all five projects. `./scripts/test-xunit.sh 4` runs the xUnit projects and `tests/DependencyModules.Specs` with `xunit.v3` version 4. To run all tests with code coverage, use the coverage script. The script writes the report to `artifacts/coverage`. If you give a percentage, the script fails when the line coverage is less than that value. diff --git a/DependencyModules.sln b/DependencyModules.sln index 1b636c9..6d62644 100644 --- a/DependencyModules.sln +++ b/DependencyModules.sln @@ -28,7 +28,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiApp.Tests", "integ-te EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F4DC9AA2-7F61-4DEE-A7D1-2BCDBEEFD1C5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyModules.Tests", "tests\DependencyModules.Tests\DependencyModules.Tests.csproj", "{1AFFBCCF-FD6E-4232-9DC7-40FE2784ECD1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DependencyModules.xUnit.Tests", "tests\DependencyModules.xUnit.Tests\DependencyModules.xUnit.Tests.csproj", "{1AFFBCCF-FD6E-4232-9DC7-40FE2784ECD1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{2E4BAA8C-195F-490B-B9F9-57194B08CD12}" EndProject diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 3ef31f1..1852112 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -27,7 +27,7 @@ mkdir -p "${OUT}" "${RAW}" # Every suite contributes: the integration projects exercise a great deal of the generator # that the unit tests never reach directly. PROJECTS=( - "tests/DependencyModules.Tests/DependencyModules.Tests.csproj" + "tests/DependencyModules.xUnit.Tests/DependencyModules.xUnit.Tests.csproj" "integ-tests/SutProject.Tests/SutProject.Tests.csproj" "integ-tests/SutProject.NUnitTests/SutProject.NUnitTests.csproj" "integ-tests/web/WebApiApp.Tests/WebApiApp.Tests.csproj" diff --git a/scripts/test-xunit.sh b/scripts/test-xunit.sh index d0fb143..668b1c7 100755 --- a/scripts/test-xunit.sh +++ b/scripts/test-xunit.sh @@ -18,7 +18,7 @@ if [ -n "${2:-}" ]; then PROPERTIES+=("-p:XunitV3Version=$2"); fi if [ -n "${3:-}" ]; then PROPERTIES+=("-p:XunitRunnerVersion=$3"); fi PROJECTS=( - "tests/DependencyModules.Tests/DependencyModules.Tests.csproj" + "tests/DependencyModules.xUnit.Tests/DependencyModules.xUnit.Tests.csproj" "integ-tests/SutProject.Tests/SutProject.Tests.csproj" "integ-tests/web/WebApiApp.Tests/WebApiApp.Tests.csproj" ) diff --git a/tests/DependencyModules.Specs/Infrastructure/Require.cs b/tests/DependencyModules.Specs/Infrastructure/Require.cs index 7dc32bc..a3acffe 100644 --- a/tests/DependencyModules.Specs/Infrastructure/Require.cs +++ b/tests/DependencyModules.Specs/Infrastructure/Require.cs @@ -3,8 +3,8 @@ namespace DependencyModules.Tests.Infrastructure; /// -/// The harness checks. They throw a plain exception, which fails the test on any runner, because -/// the harness is compiled into an xUnit project and a VerificationGlue.Tests project. +/// The harness checks. They throw a plain exception, which fails the test on any runner, so the +/// harness does not depend on a test framework. /// public static class Require { diff --git a/tests/DependencyModules.Specs/Infrastructure/Snapshot.cs b/tests/DependencyModules.Specs/Infrastructure/Snapshot.cs index 32ca6e9..f753e86 100644 --- a/tests/DependencyModules.Specs/Infrastructure/Snapshot.cs +++ b/tests/DependencyModules.Specs/Infrastructure/Snapshot.cs @@ -8,10 +8,8 @@ namespace DependencyModules.Tests.Infrastructure; /// unintended changes to generated output show up as a reviewable diff. /// /// To accept new output, re-run the tests with UPDATE_SNAPSHOTS=1: -/// UPDATE_SNAPSHOTS=1 dotnet test tests/DependencyModules.Tests /// UPDATE_SNAPSHOTS=1 scripts/test-verificationglue.sh -/// and review the resulting changes under the Snapshots folder of each project. Each project -/// reads the snapshots of its own folder. +/// and review the resulting changes under tests/DependencyModules.Specs/Snapshots. /// /// Snapshots are read from the build output, where they are copied by the project file. /// [CallerFilePath] is deliberately not used to locate them: deterministic builds diff --git a/tests/DependencyModules.Tests/DependencyModules.Tests.csproj b/tests/DependencyModules.xUnit.Tests/DependencyModules.xUnit.Tests.csproj similarity index 57% rename from tests/DependencyModules.Tests/DependencyModules.Tests.csproj rename to tests/DependencyModules.xUnit.Tests/DependencyModules.xUnit.Tests.csproj index 01b04f3..26d7cf8 100644 --- a/tests/DependencyModules.Tests/DependencyModules.Tests.csproj +++ b/tests/DependencyModules.xUnit.Tests/DependencyModules.xUnit.Tests.csproj @@ -1,5 +1,12 @@  + $(LibraryTargetFrameworks) enable @@ -14,27 +21,12 @@ - - + OutputItemType="Analyzer" ReferenceOutputAssembly="false"/> - + - - - - - - - @@ -42,9 +34,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - all @@ -66,20 +55,4 @@ - - - - - - - - <_Parameter1>SnapshotDirectory - <_Parameter2>$(MSBuildProjectDirectory)/Snapshots - - - diff --git a/tests/DependencyModules.Tests/NUnitTests/ModuleTestAttributeTests.cs b/tests/DependencyModules.xUnit.Tests/NUnitTests/ModuleTestAttributeTests.cs similarity index 100% rename from tests/DependencyModules.Tests/NUnitTests/ModuleTestAttributeTests.cs rename to tests/DependencyModules.xUnit.Tests/NUnitTests/ModuleTestAttributeTests.cs diff --git a/tests/DependencyModules.Tests/NUnitTests/NUnitDataSamples.cs b/tests/DependencyModules.xUnit.Tests/NUnitTests/NUnitDataSamples.cs similarity index 100% rename from tests/DependencyModules.Tests/NUnitTests/NUnitDataSamples.cs rename to tests/DependencyModules.xUnit.Tests/NUnitTests/NUnitDataSamples.cs diff --git a/tests/DependencyModules.Tests/TestingTests/TestContainerSourceTests.cs b/tests/DependencyModules.xUnit.Tests/TestingTests/TestContainerSourceTests.cs similarity index 100% rename from tests/DependencyModules.Tests/TestingTests/TestContainerSourceTests.cs rename to tests/DependencyModules.xUnit.Tests/TestingTests/TestContainerSourceTests.cs diff --git a/tests/DependencyModules.Tests/xUnitTests/AttributeUtilityTests.cs b/tests/DependencyModules.xUnit.Tests/xUnitTests/AttributeUtilityTests.cs similarity index 100% rename from tests/DependencyModules.Tests/xUnitTests/AttributeUtilityTests.cs rename to tests/DependencyModules.xUnit.Tests/xUnitTests/AttributeUtilityTests.cs diff --git a/tests/DependencyModules.Tests/xUnitTests/ModuleTestCaseDataTests.cs b/tests/DependencyModules.xUnit.Tests/xUnitTests/ModuleTestCaseDataTests.cs similarity index 100% rename from tests/DependencyModules.Tests/xUnitTests/ModuleTestCaseDataTests.cs rename to tests/DependencyModules.xUnit.Tests/xUnitTests/ModuleTestCaseDataTests.cs diff --git a/tests/DependencyModules.Tests/xUnitTests/ModuleTestDiscovererTests.cs b/tests/DependencyModules.xUnit.Tests/xUnitTests/ModuleTestDiscovererTests.cs similarity index 100% rename from tests/DependencyModules.Tests/xUnitTests/ModuleTestDiscovererTests.cs rename to tests/DependencyModules.xUnit.Tests/xUnitTests/ModuleTestDiscovererTests.cs