26ff8d9b4f
Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
5.4 KiB
5.4 KiB
Test Project Alignment Design
Problem
After the architecture cleanup that created the Infrastructure project and reorganized code, the unit test projects no longer align with the source code projects. The generic JdeScoping.Tests project contains tests for multiple source projects (Core and Infrastructure), and several source projects have no corresponding test projects.
Goal
Achieve 1:1 mapping between source projects and test projects, ensuring every source project has a dedicated test project.
Current State
Source Projects (9):
- JdeScoping.Api
- JdeScoping.Client
- JdeScoping.Core
- JdeScoping.DataAccess
- JdeScoping.Database
- JdeScoping.DataSync
- JdeScoping.ExcelExport
- JdeScoping.Host
- JdeScoping.Infrastructure
Test Projects (6):
- JdeScoping.Api.Tests
- JdeScoping.Api.IntegrationTests
- JdeScoping.DataAccess.Tests
- JdeScoping.DataSync.Tests
- JdeScoping.ExcelExport.Tests
- JdeScoping.Tests (generic catch-all)
Target State
Test Projects (10):
tests/
├── JdeScoping.Api.Tests/ (keep - already aligned)
├── JdeScoping.Api.IntegrationTests/ (keep - integration tests)
├── JdeScoping.Client.Tests/ (create - placeholder)
├── JdeScoping.Core.Tests/ (create - move tests from JdeScoping.Tests)
├── JdeScoping.DataAccess.Tests/ (keep - already aligned)
├── JdeScoping.Database.Tests/ (create - placeholder)
├── JdeScoping.DataSync.Tests/ (keep - already aligned)
├── JdeScoping.ExcelExport.Tests/ (keep - already aligned)
├── JdeScoping.Host.Tests/ (create - placeholder)
└── JdeScoping.Infrastructure.Tests/ (create - move tests from JdeScoping.Tests)
Deleted:
- JdeScoping.Tests (generic catch-all)
Test File Movements
| File | From | To |
|---|---|---|
| JdeDateConverterTests.cs | JdeScoping.Tests/Unit/ | JdeScoping.Core.Tests/Unit/ |
| QueryTypesTests.cs | JdeScoping.Tests/Unit/ | JdeScoping.Core.Tests/Unit/ |
| FakeAuthServiceTests.cs | JdeScoping.Tests/Unit/ | JdeScoping.Infrastructure.Tests/Unit/ |
Project Template
Standard .csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\JdeScoping.{Name}\JdeScoping.{Name}.csproj" />
</ItemGroup>
</Project>
Placeholder File (for empty projects)
// This file exists to ensure the test project compiles.
// Add tests here as needed.
namespace JdeScoping.{Name}.Tests;
public class Placeholder
{
// Tests will be added here
}
Changes Per Project
1. JdeScoping.Core.Tests (new)
- Create project with standard template
- Move
JdeDateConverterTests.csfromJdeScoping.Tests/Unit/ - Move
QueryTypesTests.csfromJdeScoping.Tests/Unit/ - Update namespace:
JdeScoping.Tests.Unit→JdeScoping.Core.Tests.Unit - Reference:
JdeScoping.Core
2. JdeScoping.Infrastructure.Tests (new)
- Create project with standard template
- Move
FakeAuthServiceTests.csfromJdeScoping.Tests/Unit/ - Update namespace:
JdeScoping.Tests.Unit→JdeScoping.Infrastructure.Tests.Unit - References:
JdeScoping.Infrastructure,JdeScoping.Core
3. JdeScoping.Client.Tests (new - placeholder)
- Create project with standard template
- Add placeholder file
- References:
JdeScoping.Client,JdeScoping.Core
4. JdeScoping.Database.Tests (new - placeholder)
- Create project with standard template
- Add placeholder file
- Reference:
JdeScoping.Database
5. JdeScoping.Host.Tests (new - placeholder)
- Create project with standard template
- Add placeholder file
- Reference:
JdeScoping.Host
6. JdeScoping.Tests (delete)
- Remove from solution file
- Delete entire directory
7. Solution File (JdeScoping.slnx)
- Add 5 new test projects
- Remove
JdeScoping.Tests
Verification
- Build succeeds -
dotnet buildpasses with 0 errors - All tests pass -
dotnet testruns successfully - Test count preserved - 81 tests from JdeScoping.Tests split between Core.Tests (~77) and Infrastructure.Tests (~4)
- 1:1 mapping achieved - Every source project has a matching test project
Expected Test Distribution
| Test Project | Expected Tests |
|---|---|
| JdeScoping.Api.Tests | 33 |
| JdeScoping.Api.IntegrationTests | 8 |
| JdeScoping.Client.Tests | 0 (placeholder) |
| JdeScoping.Core.Tests | ~77 |
| JdeScoping.DataAccess.Tests | 188 |
| JdeScoping.Database.Tests | 0 (placeholder) |
| JdeScoping.DataSync.Tests | 54 |
| JdeScoping.ExcelExport.Tests | ~45 |
| JdeScoping.Host.Tests | 0 (placeholder) |
| JdeScoping.Infrastructure.Tests | ~4 |