Search code examples
phpphpunit

How to have PHPUnit (11) Output Test Results While They Are Running


I'm currently using PHPUnit 11.4.3. In previous versions (9? 8?), it used to output the result of a test as it was run. Now, as it is running, I just get something like:

Runtime:       PHP 8.2.12
Configuration: tests\phpunit.xml

.................................................

Then after it completes, it shows all the test results.

Is there a way to have PHPUnit (v11) output the test results as it runs?

I execute the test from the command line:

vendor\bin\phpunit -c tests\phpunit.xml
PHPUnit 11.4.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.12
Configuration: tests\phpunit.xml

Here is my config file:

<?xml version="1.0"?>
<phpunit
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
    backupGlobals="true"
    backupStaticProperties="false"
    cacheDirectory=".phpunit.cache"
    cacheResult="false"
    colors="true"
    displayDetailsOnTestsThatTriggerWarnings="true"
    processIsolation="false"
    requireCoverageMetadata="false"
    stopOnError="false"
    stopOnFailure="false"
    stopOnIncomplete="false"
    stopOnSkipped="false"
    stopOnRisky="false"
    testdox="true"
    timeoutForSmallTests="1"
    timeoutForMediumTests="10"
    timeoutForLargeTests="60"
    >
    <coverage/>
    <php>
        <ini
            name="display_errors"
            value="true"/>
    </php>
    <source/>
    <testsuites>
        <testsuite name="all">
            <file>PageTests.php</file>
            <file>UnitTests.php</file>
        </testsuite>
    </testsuites>
</phpunit>

Solution

  • There was a breaking change and now TestDox mode is no longer used during report execution, it's only used for final report. This change is intentional and is not going to be reverted:

    Your only option at this moment is to write or find a PHPUnit extension that does this. I'm personally using ScriptFUSION/Pip.