testo/bridge-symfony-console
Installation:
composer require --dev testo/bridge-symfony-console
This adds the bin/testo executable to your project root.
First Run:
./bin/testo run
tests/ directory).Key Files:
vendor/bin/testo (symlink to bin/testo).testo.php in your project root (auto-generated if missing).tests/; override via --path flag or config.# Basic test run (discover tests in `tests/`):
./bin/testo run
# Run tests in a custom directory:
./bin/testo run --path=custom/tests
# Generate JUnit XML for CI/CD:
./bin/testo run --log-junit=tests/junit.xml
Extend Testo\Bridge\SymfonyConsole\Command\TestoCommand to integrate Testo into your own Symfony Console commands:
use Testo\Bridge\SymfonyConsole\Command\TestoCommand;
class MyCustomTestCommand extends TestoCommand {
protected function configure() {
$this->setName('app:test-custom')
->setDescription('Run custom test suite');
}
protected function execute(InputInterface $input, OutputInterface $output) {
$this->runTests(['--path' => 'custom/tests'], $output);
}
}
testo.php is created at first run in the project root.
return [
'paths' => [
'tests' => 'tests/',
'custom' => 'custom/tests',
],
'default_path' => 'tests',
];
./bin/testo run --path=custom/tests --filter=MyTest
bin/testo command globally:
// In AppServiceProvider@boot()
if (file_exists($this->app->basePath('bin/testo'))) {
$this->app->bind('command.testo', function () {
return new \Testo\Bridge\SymfonyConsole\Command\RunCommand();
});
$this->commands(['command.testo']);
}
app/Console/Kernel.php:
protected $commands = [
\Testo\Bridge\SymfonyConsole\Command\RunCommand::class,
];
Leverage Testo’s filtering flags:
# Run tests matching a pattern:
./bin/testo run --filter="*UserTest"
# Run specific test groups:
./bin/testo run --groups="unit,integration"
./bin/testo run --log-junit=build/logs/junit.xml
0: All tests passed.1: Some tests failed.2: Test execution error.Path Resolution:
--path flag is treated as an absolute path to the project root (not the tests directory).--path=/var/www/project (not --path=/var/www/project/tests)../bin/testo run --path=$(pwd) for relative paths.Symfony 8+ Compatibility:
init command may fail if your Symfony app uses newer container syntax (e.g., add() → addService()).testo.php or patch the init command logic.Configuration Overrides:
testo.php settings. Explicitly set defaults in config to avoid surprises:
return [
'default_path' => 'tests',
'filter' => null, // Explicitly disable filtering
];
Test Discovery Quirks:
*.php). Ensure your test files follow this pattern.--verbose to see discovered test files:
./bin/testo run --verbose
Dry Run:
./bin/testo run --dry-run
Lists tests without executing them.
Verbose Output:
./bin/testo run --verbose
Shows test discovery and execution details.
Log Levels:
--log-level=debug for granular logs (requires Testo’s debug configuration).Custom Testo Configuration:
Testo\Bridge\SymfonyConsole\TestoConfig class to add project-specific settings:
class CustomTestoConfig extends TestoConfig {
public function getCustomSetting() {
return $this->config['custom_setting'] ?? null;
}
}
$this->app->bind(TestoConfig::class, CustomTestoConfig::class);
Pre/Post-Test Hooks:
TestoCommand::runTests() to inject setup/teardown:
protected function runTests(array $args, OutputInterface $output) {
$this->setupEnvironment();
parent::runTests($args, $output);
$this->teardownEnvironment();
}
Parallel Test Execution:
--parallel flag (if supported) for faster runs:
./bin/testo run --parallel=4
Cache Test Discovery:
./bin/testo init --force
Filter Aggressively:
--filter to reduce execution time:
./bin/testo run --filter="*PerformanceTest"
Avoid JUnit Overhead:
--log-junit in local development unless needed for CI/CD.Artisan Command Conflicts:
test Artisan command, alias the Testo command to avoid conflicts:
// In app/Console/Kernel.php
protected $commands = [
\Testo\Bridge\SymfonyConsole\Command\RunCommand::class => 'testo:run',
];
php artisan testo:run
Environment-Specific Config:
// In testo.php
return [
'paths' => [
'tests' => env('TEST_PATH', 'tests'),
],
];
How can I help you explore Laravel packages today?