testo/test
Testo plugin that adds the #[Test] attribute and discovery locator. Automatically finds attribute-marked test classes and methods for canonical attribute-driven test detection. Install with composer require --dev testo/test.
#[Test] attribute plugin leverages PHP 8.1+ attributes, which aligns with Laravel’s adoption of attributes (e.g., #[Route], #[Middleware]). This reduces friction for teams already using modern PHP features.test* prefixes) with declarative attributes, improving test organization and reducing false positives in test discovery.#[Test] on private methods), a feature lacking in Laravel’s PHPUnit integration by default.#[Test] attributes. Mitigation:
\Testo\Test vs. \PHPUnit\Framework\TestCase).RefreshDatabase trait.php artisan test).DatabaseMigrations.
Workaround: Build custom Testo extensions or adapters.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Framework Lock-in | Medium | Evaluate Testo’s long-term viability vs. PHPUnit/Pest. Assess if its plugin ecosystem can replace Laravel-specific tools. |
| Attribute Conflicts | High | Enforce namespace separation or use custom attributes (e.g., #[TestoTest]). |
| Laravel Integration Gaps | High | Prioritize building adapters for critical features (e.g., database testing). |
| Documentation Gaps | High | Create Laravel-specific guides for Testo setup, CI/CD, and feature parity. |
| Performance Overhead | Low | Benchmark Testo vs. PHPUnit for Laravel-specific workloads (e.g., HTTP tests). |
| Community Support | High | Monitor php-testo/testo activity; prepare for forking if upstream stalls. |
Strategic Fit:
RefreshDatabase) or invest in custom solutions?Adoption Strategy:
phpunit.xml to Testo’s configuration?Laravel-Specific Needs:
Developer Experience:
assertThat()) with Laravel’s existing testing patterns?Long-Term Viability:
testo/test for attribute discovery).Testo\TestCase or wrap in a Laravel-specific base class (e.g., LaravelTestCase).AppServiceProvider to integrate with Laravel’s DI.testo command to mirror Laravel’s phpunit command.RefreshDatabase.phpunit calls with ./vendor/bin/testo or a custom Artisan command.Phase 1: Proof of Concept (PoC)
composer require --dev testo/testo testo/test phpunit/phpunit
#[Test] and Testo’s syntax.Phase 2: Hybrid Integration
\Tests\Unit\Testo vs. \Tests\Unit\PHPUnit).composer.json to support both:
"autoload-dev": {
"psr-4": {
"Tests\\Testo\\": "tests/testo/",
"Tests\\PHPUnit\\": "tests/phpunit/"
}
}
testo Artisan command alias.
Example:// app/Providers/TestoServiceProvider.php
public function register()
{
$this->app->singleton(TestoTestCase::class);
$this->app->bind(TestoRunner::class, function ($app) {
return new TestoRunner($app->make(TestoConfig::class));
});
$this->commands([
new TestoCommand(), // Custom Artisan wrapper
]);
}
// app/Console/Commands/TestoCommand.php
public function handle()
{
$runner = app(TestoRunner::class);
$result = $runner->run();
exit($result->exitCode());
}
Phase 3: Full Adoption
phpunit.xml with Testo’s configuration (e.g., testo.php).| Component | Compatibility Notes |
|---|---|
| Laravel Testing | Works with Laravel’s HttpTests, FeatureTests, but requires custom adapters for DatabaseMigrations, RefreshDatabase, and queue testing. |
| PHPUnit/Pest | Conflicts possible if using #[Test] in both. Solutions: |
- Use namespace isolation (e.g., \Testo\Test vs. \PHPUnit\Framework\TestCase). |
|
| - Configure Testo to ignore PHPUnit attributes via exclusion rules. | |
| Packages | Testo lacks Laravel-specific packages (e.g., laravel/browsershot, laravel/horizon). Workaround: Use Testo’s extension system or wrap existing packages in Testo-compatible adapters. |
| CI/CD | Update scripts to run ./vendor/bin/testo or php artisan testo. May require custom reporters for CI integration (e.g., GitHub Actions, Jenkins). |
| Database Testing | Testo’s transactional tests can replace Laravel’s RefreshDatabase, but custom setup is needed for migrations, seeding, and rollbacks |
How can I help you explore Laravel packages today?