Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

php-testo/testo

Repository files navigation

TESTO

The PHP Testing Framework You Control


Testo is an extensible testing framework built on a lightweight core with a middleware system. It gives you full control over your testing environment while keeping the familiar PHP syntax you already know.

Get Started

Installation

composer require --dev testo/testo *

PHP Latest Version on Packagist License Total Destroys

Configuration

By default, if no configuration file is provided, Testo will run tests from the tests folder.

To customize the configuration, 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\FinderConfig;
use Testo\Application\Config\SuiteConfig;
return new ApplicationConfig(
 suites: [
 new SuiteConfig(
 name: 'Unit',
 location: new FinderConfig(
 include: ['tests/Unit'],
 ),
 ),
 ],
);

Running Tests

To run your tests, execute:

vendor/bin/testo

Writing Your First Test

Create a test class in the configured test directory (e.g., tests/CalculatorTest.php):

<?php
declare(strict_types=1);
namespace Tests;
use Testo\Application\Attribute\Test;
use Testo\Assert;
use Testo\Assert\ExpectException;
use Testo\Retry\RetryPolicy;
final class CalculatorTest
{
 #[Test]
 public function dividesNumbers(): void
 {
 $result = 10 / 2;
 Assert::same(5.0, $result);
 Assert::notSame(5, $result); // Types matter!
 }
 #[Test]
 #[RetryPolicy(maxAttempts: 3)]
 public function flakyApiCall(): void
 {
 // Retries up to 3 times if test fails
 $response = $this->makeExternalApiCall();
 Assert::same(200, $response->status);
 }
 #[Test]
 #[ExpectException(\RuntimeException::class)]
 public function throwsException(): void
 {
 throw new \RuntimeException('Expected error');
 }
}

What to note:

  • Use the #[Test] attribute to mark test methods
  • Test classes don't need to extend any base class
  • Use Assert class for assertions (same, true, false, null, contains, instanceOf, etc.)
  • Testo provides multiple attributes to extend testing capabilities (retry policies, exception handling, and more)

IDE Support

Testo comes with the IDEA plugin Testo.

Version Rating Downloads

About

The Testing Framework

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 7

Languages

AltStyle によって変換されたページ (->オリジナル) /