Getting Started
Installation
Install Testo via Composer:
composer require --dev testo/testoConfiguration
By default, if no configuration file is provided, Testo will run tests from the tests folder.
To configure Testo, create a testo.php file in the root of your project:
<?php
declare(strict_types=1);
use Testo\Application\Config\ApplicationConfig;
use Testo\Application\Config\SuiteConfig;
use Testo\Application\Config\FinderConfig;
return new ApplicationConfig(
suites: [
new SuiteConfig(
name: 'Unit',
location: ['tests/Unit'],
),
new SuiteConfig(
name: 'Sources',
location: ['src'],
),
],
);In this example we defined two test suites: Unit for unit tests located in tests/Unit, and Sources for inline tests and benchmarks right in the project source code, in the src folder.
To learn more about configuration, visit the Configuration section.
Writing Your First Test
Create a test class in the configured directory (e.g., tests/Unit/MyFirstTest.php) and add a method with the #[Test]#[Test()]Explicitly marks a method, function, or class as a test. attribute:
final class MyFirstTest
{
#[Test]
public function dividesNumbers(): void
{
$result = 10 / 2;
Assert::same($result, 5.0);
Assert::notSame($result, 5); // Types matter
}
}The #[Test]#[Test()]Explicitly marks a method, function, or class as a test. attribute marks the method as a test, and the Assert\Testo\Assert facade checks assertions. More about test approaches, attributes, and conventions — in Writing Tests.
Running Tests
To run your tests, execute:
vendor/bin/testoYou should see output showing the test results with detailed information about passed and failed tests.
IDE Support
Testo comes with an official IDEA plugin for PhpStorm and IntelliJ IDEA.
Testo for PhpStormThe plugin provides:
- Running tests directly from the IDE
- Navigation between test and implementation code
- Test result visualization
- Debugging support