Search code examples
phpunit-testingphpunit

An error occurred, but no information is displayed


PS : I am new to StackOverflow and in computer science. My question may be blurry, so please be understanding and kindly tell me what I can improve :)

I am currently testing my code with PhpUnit before deploying it.

Every test passes with success, but I still get this message :

ERRORS!
Tests: 108, Assertions: 154, Errors: 1.

I need to find out what this error is about but no information about this error is displayed ! I turned on all "display_errors" kind of parameters in my php.ini file but nothing seems to work.

Is there a simple way to find this error's cause ?

Here is my command line :

C:\php\php.exe C:/Users/me/AppData/Local/Temp/ide-phpunit.php --bootstrap C:\Users\me\PhpstormProjects\myProject\tests\bootstrap.php --configuration C:\Users\me\PhpstormProjects\myProject\tests\phpunit.xml C:\Users\me\PhpstormProjects\myProject\tests\myTests

And here is my phpunit.xml file :

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="bootstrap.php" colors="true"
         cacheResult="false" testdox="true"
         displayDetailsOnTestsThatTriggerWarnings="true"
         cacheDirectory=".phpunit.cache" backupGlobals="true">
</phpunit>

My bootstrap file contains only a simple autoloader, and I'm on php 8.3.7 and phpUnit 11.1.3.


Solution

  • I managed to find the error. I did not want to test all the 108 tests one-by-one ... The --stop-on-defect argument did the job and I found that the error was located in a setUp() method :)

    I'm still confused about why every test passed with success even though the setUp() failed ... And It would be a usefull functionnality for phpUnit to display error even when they're outside tests !