Not very helpful error messages from BrowserTestBase (test runner returned a non-zero error code 255)

Viewed 109

I'm trying to run some browser tests after upgrading my drupal version to 9.0.10 and updating a bunch of other packages in the process. I run my tests with the following command:

php core/scripts/run-tests.sh --verbose --php /usr/local/bin/php

The tests fail, but the error message isn't really helping me identify why. It just says that test runner (I don't know what that is) failed with code 255:

Drupal test run
---------------

Tests to be run:
  - Drupal\Tests\innovations\Functional\ImplementThisIdeaBlock
  - Drupal\Tests\innovations\Functional\InnovationsBrowserTestBase
  - Drupal\Tests\innovations\Functional\CreateIdeaForm
  - Drupal\Tests\innovations\Functional\CreateIdeaToSolveThisProblemBlock
  - Drupal\Tests\innovations\Functional\CreateImplementationForm

Test run started:
  Friday, December 25, 2020 - 03:50

Test summary
------------

Drupal\Tests\innovations\Functional\CreateIdeaToSolveThisPro   0 passes
Drupal\Tests\innovations\Functional\InnovationsBrowserTestBa   0 passes
Drupal\Tests\innovations\Functional\CreateImplementationForm   0 passes
Drupal\Tests\innovations\Functional\CreateIdeaForm             0 passes
Drupal\Tests\innovations\Functional\ImplementThisIdeaBlock     0 passes
FATAL Drupal\Tests\innovations\Functional\ImplementThisIdeaBlock: test runner returned a non-zero error code (255).
Drupal\Tests\innovations\Functional\ImplementThisIdeaBlock     0 passes   1 fails
FATAL Drupal\Tests\innovations\Functional\InnovationsBrowserTestBase: test runner returned a non-zero error code (255).
Drupal\Tests\innovations\Functional\InnovationsBrowserTestBa   0 passes   1 fails
FATAL Drupal\Tests\innovations\Functional\CreateIdeaForm: test runner returned a non-zero error code (255).
Drupal\Tests\innovations\Functional\CreateIdeaForm             0 passes   1 fails
FATAL Drupal\Tests\innovations\Functional\CreateIdeaToSolveThisProblemBlock: test runner returned a non-zero error code (255).
Drupal\Tests\innovations\Functional\CreateIdeaToSolveThisPro   0 passes   1 fails
FATAL Drupal\Tests\innovations\Functional\CreateImplementationForm: test runner returned a non-zero error code (255).
Drupal\Tests\innovations\Functional\CreateImplementationForm   0 passes   1 fails

Test run duration: 0 sec

Detailed test results
---------------------


---- Drupal\Tests\innovations\Functional\CreateIdeaForm ----


Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Fail      run-tests. Unknown              0 Unknown
    FATAL Drupal\Tests\innovations\Functional\CreateIdeaForm: test runner
    returned a non-zero error code (255).


---- Drupal\Tests\innovations\Functional\CreateIdeaToSolveThisProblemBlock ----


Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Fail      run-tests. Unknown              0 Unknown
    FATAL
    Drupal\Tests\innovations\Functional\CreateIdeaToSolveThisProblemBlock: test
    runner returned a non-zero error code (255).


---- Drupal\Tests\innovations\Functional\CreateImplementationForm ----

Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Fail      run-tests. Unknown              0 Unknown
    FATAL Drupal\Tests\innovations\Functional\CreateImplementationForm: test
    runner returned a non-zero error code (255).

Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Fail      run-tests. Unknown              0 Unknown
    FATAL Drupal\Tests\innovations\Functional\CreateImplementationForm: test
    runner returned a non-zero error code (255).


---- Drupal\Tests\innovations\Functional\ImplementThisIdeaBlock ----


Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Fail      run-tests. Unknown              0 Unknown
    FATAL Drupal\Tests\innovations\Functional\ImplementThisIdeaBlock: test
    runner returned a non-zero error code (255).


---- Drupal\Tests\innovations\Functional\InnovationsBrowserTestBase ----


Status    Group      Filename          Line Function
--------------------------------------------------------------------------------
Fail      run-tests. Unknown              0 Unknown
    FATAL Drupal\Tests\innovations\Functional\InnovationsBrowserTestBase: test
    runner returned a non-zero error code (255).

What can I do to glean a bit more information on what's going on here?

1 Answers

Exit code 255 indicates that PHP had a fatal error and crashed. You should be able to get a useful error message by enabling reporting.

There are several ways to do this:

  1. In your code:
    1. Put this before any imports in both the unit test and unit under test files that are failing. This is my preferred approach, as the in code option takes precedence over the two options mentioned below, and sometimes there is code lurking in the application that explicitly disables error reporting.
      error_reporting(E_ERROR);
      
    2. More details at https://www.php.net/manual/en/function.error-reporting.php
  2. Use PHP CLI options: php -derror_reporting=1 ...
  3. Set error_reporting in php.ini file
Related