| name | test |
| description | Guidelines for frontend component and E2E testing in FinanzApp. |
Testing (BackEnd)
Context
Quality assurance in the Backend involves checking business logic, data persistence, and API behavior using xUnit and Moq.
Guidelines
- Unit Testing:
- Use xUnit for unit testing business logic in
Services and Domain.
- Use Moq to isolate dependencies (e.g., repositories, external services).
- Follow the AAA pattern (Arrange, Act, Assert).
- Persistence Testing: Use
EF Core In-Memory database to validate repository logic and business rules that involve data persistence without needing a real SQL Server.
- Integration Testing: Use
WebApplicationFactory to test the full API pipeline (Controllers + Services + DB) by making real HTTP calls to a test server.
- Assertions: Use clear assertions. Prefer
FluentAssertions if available, or standard Assert methods from xUnit.
- Naming Strategy: Test methods should follow a clear naming convention:
[Subject]_[Scenario]_[ExpectedResult].
- Example:
GetById_UserDoesNotExist_ReturnsNotFound.