jasonmccreary/phpunit-tia

Test Impact Analysis for PHPUnit

Maintainers

Package info

github.com/jasonmccreary/phpunit-tia

pkg:composer/jasonmccreary/phpunit-tia

Transparency log

Statistics

Installs: 64

Dependents: 0

Suggesters: 0

Stars: 13

Open Issues: 0

v0.1.1 2026-07-31 19:00 UTC

This package is auto-updated.

Last update: 2026-08-02 14:58:23 UTC


README

This is a port of Pest's new TIA Engine. Test Impact Analysis (TIA) greatly improves test suite performance by only running tests which relate to impacted (changed) files. This plugin brings the same performance improvements to PHPUnit.

Installation

This plugin requires PHPUnit 13 and PHP 8.4, as well as a code coverage driver (pcov or Xdebug in coverage mode) to record new coverage. If you are not running PHPUnit 13, you may use Shift to automate the upgrade.

composer require --dev jasonmccreary/phpunit-tia

Next, register the extension in your PHPUnit configuration:

<extensions>
    <bootstrap class="JMac\Testing\PhpUnit\Tia\Extension">
        <parameter name="storage" value="global"/>
    </bootstrap>
</extensions>

Usage

To enable TIA, add the trait to your base TestCase:

use JMac\Testing\PhpUnit\Tia\Traits\RunWithTia;

abstract class TestCase extends \PHPUnit\Framework\TestCase
{
    use RunWithTia;
}

This will activate TIA for every phpunit invocation. Since third-party plugins can not change the PHPUnit test runner, TIA marks unimpacted tests as skipped (S) to achieve faster replay speeds.

Note: if your TestCase already declares setUp(), you will need to alias and call the trait's setUp explicitly:

abstract class TestCase extends \PHPUnit\Framework\TestCase
{
    use RunWithTia {
        RunWithTia::setUp as tiaSetUp;
    }

    protected function setUp(): void
    {
        $this->tiaSetUp();

        // ...your own setUp logic
    }
}

To bypass TIA, you may pass an environment variable at runtime:

PHPUNIT_TIA=0 phpunit ...

While a baseline will be established automatically, you may pass an environment variable to rebuild:

PHPUNIT_TIA_FRESH=1 phpunit ...

Note: running tests with the --fail-on-skipped or --display-skipped option will automatically bypass TIA's speed boost. You will need to drop these options to take full advantage of TIA.

CI Workflows

To use TIA in CI, your baseline graph must persist between runs. See our own GitHub Action workflow for an example. At a high level, your workflow needs to:

  • Check out with full git history (fetch-depth: 0), since TIA diffs against a baseline commit
  • Re-attach HEAD to the real branch name, since a detached HEAD collapses baselines across branches
  • Cache TIA's storage directory (~/.phpunit-tia for global storage, or the configured path for local) keyed per-branch/runner, and save it after every run

Note: TIA is intended to reduce the feedback loop during development. As such, an ideal workflow is using TIA in local environments and running the full test suite in CI environments.

Contributing

You may contribute by opening a Pull Request with your changes. All PRs should target main, include tests to verify your change, and pass the GitHub Action workflows.