Files
raceplanner/openspec/changes/add-tests/specs/backend-unit-tests/spec.md
T

38 lines
1.6 KiB
Markdown
Raw Normal View History

2026-04-05 22:16:44 +02:00
## ADDED Requirements
### Requirement: Backend test project exists
The system SHALL have a dedicated .NET test project named `backend.Tests` that references the main `backend` project.
#### Scenario: Test project references main project
- **WHEN** the test project is built
- **THEN** it SHALL have a project reference to the main backend API project
### Requirement: Controllers can be unit tested
The system SHALL provide the ability to unit test API Controllers with mocked dependencies.
#### Scenario: Controller with mocked service
- **WHEN** a controller action is invoked with a mocked service
- **THEN** the test SHALL verify the correct HTTP response is returned
#### Scenario: Controller input validation
- **WHEN** invalid input is passed to a controller action
- **THEN** the test SHALL verify validation errors are returned
### Requirement: Services can be unit tested
The system SHALL provide the ability to unit test business logic in Services with mocked dependencies.
#### Scenario: Service with mocked repository
- **WHEN** a service method is called with a mocked data repository
- **THEN** the test SHALL verify the expected business logic is executed
### Requirement: Test utilities are available
The system SHALL provide common test utilities for setup, teardown, and assertions.
#### Scenario: Mock data factories
- **WHEN** tests require test data
- **THEN** factory classes SHALL generate consistent mock entities
#### Scenario: HTTP context mocking
- **WHEN** tests need to simulate HTTP requests
- **THEN** utilities SHALL provide mocked HttpContext and User claims