| name | test-enforcement |
| description | Mandatory rule requiring a corresponding test file for every business logic file and UI component. |
Test Enforcement (BackEnd)
Context
To maintain 100% reliability and prevent logic regressions in the FinanzApp Backend, it is OBLIGATORY that every file containing business logic, services, or repositories has a corresponding test file.
Guidelines
- Rule of One: Every
.cs file in Services/, Data/Repositories/, WebAPI/Endpoints/, or Core/ MUST have a matching test file in the Tests/ project.
- Location (Mandatory Naming):
- Test folders MUST follow the pattern
Unit.[NombreDeCarpeta].
- Example:
Tests/Unit.Services/, Tests/Unit.Data/.
- Namespace MUST be
Tests.Unit.[NombreDeCarpeta].
- Naming: If the class is
AuthService.cs, the test file MUST be AuthServiceTests.cs.
- Content:
- Logic/Services: Tests must cover main success paths and edge cases using Moq for dependencies.
- Repositories: Tests should validate EF Core queries and persistence rules (using In-Memory DB).
- Simultaneous Creation/Modification: If a testable class is created, its corresponding test class MUST be created simultaneously. If logic is altered, its corresponding tests MUST be updated.
Examples
Correct Structure
Services/
└── AuthService.cs
Tests/
└── Services/
└── AuthServiceTests.cs
Incorrect Structure (Missing Test)
Services/
└── AuthService.cs
(Error: Missing AuthServiceTests.cs in Tests project)