Test filtering plugin
Important
Active development of the Testo project lives in php-testo/testo under plugin/filter/. This repository is automatically synchronized from there on every release.
File issues and pull requests in the main monorepo, not here.
Selects which tests run on a given invocation by name patterns, paths, suites, types, dataset pointers, and groups. Powers Testo's --filter, --path, --suite, --type, and --group CLI flags.
Label tests with the #[Group] attribute and select them with --group:
use Testo\Filter\Group;
use Testo\Test;
#[Test]
#[Group('integration')] // every test of this class inherits "integration"
final class OrderTest
{
#[Group('slow')] // groups: integration, slow
public function importsLargeDataset(): void { /* ... */ }
public function createsOrder(): void { /* ... */ } // groups: integration
}The attribute targets classes, methods, and functions and accepts several names at once
(#[Group('db', 'slow')]). A test's group set is the union of all groups reachable from it:
its own method (and any overridden parent method), the test class, its parent classes, and traits.
# Run only tests in the "db" or "integration" group (OR logic)
./vendor/bin/testo run --group=db --group=integration
# Exclude a group with the "!" prefix (run everything except "slow")
./vendor/bin/testo run --group=!slow
# Combine with other filters (AND between filter types)
./vendor/bin/testo run --group=db --filter=OrderTestExclusion (!) takes precedence over inclusion. Group filters combine with name/path/suite/type
filters using AND logic.
composer require --dev testo/filter