You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I made an empty test case, which generally throws some error now it barfs.
No output file from PHPUnit is made either.
Current behavior & How to reproduce
Make a test case like this one:
class Crappy_Test extends \PHPUnit\Framework\TestCase
{
}
Then run PHPUnit and you'll get this output:
PHP Warning: Invalid argument supplied for foreach() in /[redacted]/vendor/phpunit/phpunit/src/Util/TestDox/XmlResultPrinter.php on line 193
Method PHPUnit\Framework\WarningTestCase::Warning() does not exist
I expected it to just emit a warning, or write a warning about the empty test case to my log file (junit logger).
If I add a function to the class, eg test_something() that is empty, then it passes through no problem and writes that this test is Risky
I think PHPUnit should not abruptly stop when a TestCase script file has zero functions that are test* types. It should tell me I'm doing it wrong in the output file, like with other Risky or Warnings.
The text was updated successfully, but these errors were encountered:
$ phpunit Test.php
PHPUnit 9.5.3-5-gaad51c070 by Sebastian Bergmann and contributors.
W 1 / 1 (100%)
Time: 00:00.019, Memory: 4.00 MB
There was 1 warning:
1) Warning
No tests found in class "Test".
WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.
$ phpunit --testdox-xml testdox.xml Test.php
PHPUnit 9.5.3-5-gaad51c070 by Sebastian Bergmann and contributors.
W 1 / 1 (100%)
Warning: foreach() argument must be of type array|object, null given in /usr/local/src/phpunit/src/Util/TestDox/XmlResultPrinter.php on line 193
Method PHPUnit\Framework\WarningTestCase::Warning() does not exist
sebastianbergmann
changed the title
Empty Test Case Warning Throws Error
Empty test case class causes error in TestDox XML logger
Mar 23, 2021
Summary
I made an empty test case, which generally throws some error now it barfs.
No output file from PHPUnit is made either.
Current behavior & How to reproduce
Make a test case like this one:
Then run PHPUnit and you'll get this output:
And running with xdebug enabled gives this
Expected behavior
I expected it to just emit a warning, or write a warning about the empty test case to my log file (junit logger).
If I add a function to the class, eg
test_something()
that is empty, then it passes through no problem and writes that this test is RiskyI think PHPUnit should not abruptly stop when a TestCase script file has zero functions that are
test*
types. It should tell me I'm doing it wrong in the output file, like with other Risky or Warnings.The text was updated successfully, but these errors were encountered: