Testing Strategy & Automation
Relevant source files
The following files were used as context for generating this wiki page:
RateGuru employs a multi-layered testing strategy that integrates automated unit, feature, and browser testing with rigorous documentation verification and visual regression checks. The project mandates a Test-Driven Development (TDD) approach, ensuring that every task is validated by automated tests before implementation.
The automation framework is built on PHPUnit and Pest, focusing on validating core business logic in Actions, technical helpers in Services, and ensuring UI consistency against the PlateRate Reference Composition.
Sources: AGENTS.md:12-18, phpunit.xml:7-17
Testing Layers and Tooling
The testing environment is configured to use an in-memory SQLite database to ensure high performance and isolation during test execution. The automation suite is categorized into three primary directories:
| Suite | Description | Directory |
|---|---|---|
| Unit | Isolated testing of individual classes and methods. | tests/Unit |
| Feature | Integration tests covering HTTP requests, Livewire components, and Filament pages. | tests/Feature |
| Browser | End-to-end testing of user journeys using Laravel Dusk. | tests/Browser |
Sources: phpunit.xml:8-16, phpunit.xml:30-31
Test-Driven Development (TDD) Workflow
Development follows a strict TDD cycle enforced by agent rules:
- Write a test first for any testable task.
- Run related tests before starting implementation.
- Implement the minimal code required to pass.
- Run related tests again after implementation.
- Ensure no failing tests are skipped.
Sources: AGENTS.md:20-26, CONTRIBUTING.md:16-18
Feature and UI Validation
Feature tests in RateGuru go beyond functional verification to include UI structure and design token adherence. Tests validate that the application shell renders correctly and utilizes the approved RateGuru design tokens (e.g., bg-rg-bg, text-rg-accent).
The diagram shows the standard flow of a feature test validating both logic and UI appearance.
Sources: tests/Feature/ApplicationShellTest.php:12-40, tests/Feature/Filament/ProjectSettingsValidationTest.php:7-15
Validation Targets
Tests specifically target the following areas:
- Component Isolation: Ensuring sidebar and header data preparation remains in the composer layer, keeping partials thin.
- Form Validation: Validating Filament resource pages, such as ensuring site names and theme selections meet requirements.
- Visual Baselines: Maintaining 375px breakpoint baselines for mobile feeds and profile headers.
Sources: tests/Feature/ApplicationShellTest.php:54-73, tests/Feature/Filament/ProjectSettingsValidationTest.php:17-48, tests/Feature/Docs/Phase48MobileBaselinesTest.php:10-18
Documentation and Checklist Automation
A unique aspect of RateGuru's automation is the use of automated tests to verify the existence and integrity of technical documentation and review checklists. This ensures that deployment procedures, API strategies, and UX guidelines are always up-to-date and accessible.
Automated Documentation Verification
Tests verify that critical Markdown files contain mandatory instructions, such as:
- Prohibiting
migrate:freshin production checklists. - Mandating the use of the
rateguru:admin:createcommand for admin setup. - Ensuring the "Visual Review" section exists in the Pull Request template.
Sources: tests/Feature/Docs/DeploymentDocsTest.php:16-20, tests/Feature/Docs/DeploymentDocsTest.php:67-75, tests/Feature/Docs/PullRequestTemplateTest.php:5-18
Configuration for Testing
The testing environment is strictly controlled via phpunit.xml to prevent side effects and ensure consistency across development environments.
| Environment Variable | Value | Purpose |
|---|---|---|
APP_ENV | testing | Switches application to testing mode. |
DB_CONNECTION | sqlite | Uses SQLite for database operations. |
DB_DATABASE | :memory: | Ensures a clean state for every test run. |
QUEUE_CONNECTION | sync | Executes jobs immediately during tests. |
CACHE_STORE | array | Prevents persistent caching between tests. |
Sources: phpunit.xml:24-38
Pull Request and Quality Gates
The Definition of Done (DoD) requires all tests to pass and all acceptance criteria to be satisfied before a task is considered complete. The project utilizes a Pull Request template that includes a mandatory "Mobile QA" checklist and "Visual Review" smoke tests for key pages like the desktop feed and upload modal.
Sources: AGENTS.md:76-82, tests/Feature/Docs/Phase48PrTemplateTest.php:10-18, tests/Feature/Docs/PullRequestTemplateTest.php:12-22
The combination of TDD, strict architectural rules (thin controllers, logic in Actions), and automated documentation checks forms a robust safety net that maintains high code quality and design consistency across the RateGuru platform.