Skip to content

Fatal error: Uncaught TypeError: ParaTest\Logging\LogInterpreter::mergeReaders #1039

@caherrera

Description

@caherrera
Q A
ParaTest version 6.11.1
PHPUnit version 9.6.29
PHP version 8.4.5, 8.3.10

Summary

Fatal TypeError in LogInterpreter::mergeReaders when generating a JUnit report for a file with zero tests.

Current behavior

When running ParaTest with the --log-junit option on a test file that results in "0 tests, 0 assertions", it throws a fatal error instead of generating the report.

PHP Fatal error: Uncaught TypeError: ParaTest\Logging\LogInterpreter::mergeReaders(): Return value must be of type ParaTest\Logging\JUnit\TestSuite, null returned in /var/www/html/vendor/brianium/paratest/src/Logging/LogInterpreter.php:93

How to reproduce: command, code and error stack trace

  1. Create a PHPUnit test file that contains no actual tests (or is empty), for example ./tests/Unit/SissueUnitTest.php.
  2. Run ParaTest with the --log-junit flag targeting that specific file.
  3. The following command will trigger the error:
./vendor/bin/paratest --processes=4 --testdox --log-junit=results.xml ./tests/Unit/SissueUnitTest.php
Full error stack trace:

ParaTest v6.11.1 upon PHPUnit 9.6.29 by Sebastian Bergmann and contributors.

Time: 00:00.113, Memory: 36.65 MB

OK (0 tests, 0 assertions)
PHP Fatal error:  Uncaught TypeError: ParaTest\Logging\LogInterpreter::mergeReaders(): Return value must be of type ParaTest\Logging\JUnit\TestSuite, null returned in /var/www/html/vendor/brianium/paratest/src/Logging/LogInterpreter.php:93
Stack trace:
#0 /var/www/html/vendor/brianium/paratest/src/Logging/JUnit/Writer.php(61): ParaTest\Logging\LogInterpreter->mergeReaders()
#1 /var/www/html/vendor/brianium/paratest/src/Logging/JUnit/Writer.php(86): ParaTest\Logging\JUnit\Writer->getXml()
#2 /var/www/html/vendor/brianium/paratest/src/Runners/PHPUnit/BaseRunner.php(162): ParaTest\Logging\JUnit\Writer->write()
#3 /var/www/html/vendor/brianium/paratest/src/Runners/PHPUnit/BaseRunner.php(133): ParaTest\Runners\PHPUnit\BaseRunner->log()
#4 /var/www/html/vendor/brianium/paratest/src/Runners/PHPUnit/BaseRunner.php(82): ParaTest\Runners\PHPUnit\BaseRunner->complete()
#5 /var/www/html/vendor/brianium/paratest/src/Console/Commands/ParaTestCommand.php(102): ParaTest\Runners\PHPUnit\BaseRunner->run()
#6 /var/www/html/vendor/symfony/console/Command/Command.php(326): ParaTest\Console\Commands\ParaTestCommand->execute()
#7 /var/www/html/vendor/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run()
#8 /var/www/html/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
#9 /var/www/html/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
#10 /var/www/html/vendor/brianium/paratest/bin/paratest(37): Symfony\Component\Console\Application->run()
#11 /var/www/html/vendor/bin/paratest(119): include('...')
#12 {main}
  thrown in /var/www/html/vendor/brianium/paratest/src/Logging/LogInterpreter.php on line 93

Expected behavior

ParaTest should not throw a fatal error when running against a test file that contains zero tests. It should generate a valid, possibly empty, JUnit XML report file (results.xml) and exit gracefully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions