🧪 Testing and Validation Strategy
GenDI uses layered validation:
This validation matrix aligns with the canonical Phase 6 status source in /home/runner/work/GenDI/GenDI/docs/ROTEIRO_FASE6.md (including 4.6 marked as delivered).
1️⃣ Generator behavior tests
Projects:
GenDI.SourceGenerator.CoverageEnabled.TestsGenDI.SourceGenerator.CoverageDisabled.TestsGenDI.SourceGenerator.NoCoverageAttribute.Tests
Coverage includes:
- ✅ generated coverage attribute behavior
- ✅ constructor/init-property activation generation
- ✅ ordering rules (
Group,Order, name) - ✅ contract discovery and fallback behavior
- ✅ registration strategy policy coverage (
RegistrationMultiplicity,RegistrationEmissionStrategy) - ✅ OptionConfig evolution scenarios (optional key fallback and eligibility constraints)
2️⃣ Runtime integration tests
Project:
GenDI.Integration.Tests
Covers realistic IServiceCollection composition, including open generic manual registrations and mixed generated/non-generated dependencies.
3️⃣ Publish compatibility tests
Project:
GenDI.Phase3.Validation.Tests
Executes trim/AOT publish verification paths.
4️⃣ Platform/framework validation
Projects:
GenDI.Phase6.MinimalApiValidation.AppGenDI.Phase6.WorkerValidation.AppGenDI.Phase6.BlazorWasmValidation.AppGenDI.Phase6.PlatformValidation.Tests
Covers:
- ✅ Minimal API publish validation
- ✅ Worker Service publish validation
- ✅ Blazor WebAssembly publish validation
- ✅ F# exploration proving generated
AddGenDIServices()is currently unavailable infsproj
5️⃣ Testing ergonomics (GenDI.Testing)
Projects:
GenDI.Testing.TestsGenDI.Testing.Example.Tests
Covers:
- ✅
ServiceBuilderfluent helper for test-timeIServiceCollectioncomposition - ✅ Integration with DI abstractions descriptor helpers (
TryAdd,Replace,TryAddEnumerable) - ✅ Real-world xUnit usage with generated
AddGenDIServicesand property injection
🛠️ Local validation commands
dotnet build GenDI.slnx
dotnet test GenDI.slnx
dotnet test tests/GenDI.Phase6.PlatformValidation.Tests -c Release
dotnet test tests/GenDI.Testing.Tests
dotnet test tests/GenDI.Testing.Example.Tests