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
If you made error in TestCase, like calling non_existing_function(), you get error, which tells you nothing. In this case, I'm not able to find, that problem is non_existing_function().
class CombiPneuTestSnazzyBee extends PHPUnit\Framework\TestCase {
public static function setUpBeforeClass() {
non_existing_function();
}
}
Produce:
PHP Fatal error: Uncaught Error: Call to a member function fail() on null in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php:116
Stack trace:
#0 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestResult.php(265): PHPUnit\Util\TestDox\CliTestDoxPrinter->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0) #1 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestSuite.php(754): PHPUnit\Framework\TestResult->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0) #2 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/TestRunner.php(529): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult)) #3 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php(198): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true) #4 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php( in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php on line 116
Fatal error: Uncaught Error: Call to a member function fail() on null in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php:116
Stack trace:
#0 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestResult.php(265): PHPUnit\Util\TestDox\CliTestDoxPrinter->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0) #1 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestSuite.php(754): PHPUnit\Framework\TestResult->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0) #2 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/TestRunner.php(529): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult)) #3 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php(198): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true) #4 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php( in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php on line 116
The text was updated successfully, but these errors were encountered:
<?phpdeclare(strict_types=1);
usePHPUnit\Framework\TestCase;
class Test extends TestCase
{
publicstaticfunctionsetUpBeforeClass(): void
{
does_not_exist();
}
publicfunctiontestOne(): void
{
$this->assertTrue(true);
}
}
$ phpunit --testdox Test
PHPUnit 7.1.4 by Sebastian Bergmann and contributors.
PHP Fatal error: Uncaught Error: Call to a member function fail() on null in /usr/local/src/phpunit/src/Util/TestDox/CliTestDoxPrinter.php:116
sebastianbergmann
changed the title
fail() on null
CliTestDoxPrinter::addError() cannot handle errors in setUpBeforeClass()
Apr 28, 2018
If you made error in TestCase, like calling non_existing_function(), you get error, which tells you nothing. In this case, I'm not able to find, that problem is non_existing_function().
class CombiPneuTestSnazzyBee extends PHPUnit\Framework\TestCase {
}
Produce:
PHP Fatal error: Uncaught Error: Call to a member function fail() on null in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php:116
Stack trace:
#0 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestResult.php(265): PHPUnit\Util\TestDox\CliTestDoxPrinter->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0)
#1 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestSuite.php(754): PHPUnit\Framework\TestResult->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0)
#2 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/TestRunner.php(529): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#3 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php(198): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
#4 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php( in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php on line 116
Fatal error: Uncaught Error: Call to a member function fail() on null in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php:116
Stack trace:
#0 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestResult.php(265): PHPUnit\Util\TestDox\CliTestDoxPrinter->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0)
#1 phar://REAL_PATH/phpunit.phar/phpunit/Framework/TestSuite.php(754): PHPUnit\Framework\TestResult->addError(Object(PHPUnit\Framework\TestSuite), Object(PHPUnit\Framework\ExceptionWrapper), 0)
#2 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/TestRunner.php(529): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#3 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php(198): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
#4 phar://REAL_PATH/phpunit.phar/phpunit/TextUI/Command.php( in phar://REAL_PATH/phpunit.phar/phpunit/Util/TestDox/CliTestDoxPrinter.php on line 116
The text was updated successfully, but these errors were encountered: