Skip to content
...

Getting Started

Installation

Install Testo via Composer:

bash
composer require --dev testo/testo

PHPLatest Version on PackagistLicenseTotal Downloads

Configuration

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
<?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:

php
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:

bash
vendor/bin/testo

You 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.

PSTesto for PhpStorm JetBrains Marketplace 4.1280 downloads

The plugin provides:

  • Running tests directly from the IDE
  • Navigation between test and implementation code
  • Test result visualization
  • Debugging support