---
description: Testing conventions and standards
globs: "**/*Tests.swift,**/*Test.swift,**/Tests/**"
---

## Testing Rules

### Naming

- Test files: `{ClassName}Tests.swift`
- Test methods: `test{Scenario}_{Expected}` or `test{WhatItDoes}`
- Example: `testLoginWithInvalidEmail_ShowsError()`

### Structure

- Arrange / Act / Assert pattern
- One assertion concept per test (multiple XCTAssert for same concept is OK)
- Use `setUp()` for common setup, `tearDown()` for cleanup

### Framework

- Prefer Swift Testing (`@Test`, `#expect`) for new tests
- XCTest for UI tests and existing test suites
- No `sleep()` in tests  -  use expectations/async

### Coverage

- All public methods must have tests
- All error paths must have tests
- Edge cases: nil, empty, boundary values

### Don'ts

- No network calls in unit tests  -  use mocks/stubs
- No file system dependencies  -  use temporary directories
- No test interdependencies  -  each test must be isolated
- No `XCTAssertTrue(result != nil)`  -  use `XCTAssertNotNil(result)`
